2013-08-02 58 views
2

我有(URL1的重定向后URL),不是被编码解码URL后重定向链接

String url1="http://bitake.com/params/?attribute=3" 

这里URL2一个为url1编码

String url2="http://search.bitake.com/params/?attr=48%e6%99%82%e9%96%93%e3%82" 

我用这个链接打开browswer与意向

Intent browserIntent = new Intent("android.intent.action.VIEW", 
             Uri.parse(URLDecoder.decode(url)); 
startActivity(browserIntent); 

我想通过code..Then解码URL2从URL1得到URL2到可以在网页 打开我该怎么办?

回答

0

我认为你的url1不是一个有效的网址。不能既不UTF8也不GB

0

您URL1是不是一个有效的URL进行解码,以有效的URL。 URLDecoder.decode(字符串url)已弃用。你应该使用URLDecode.decode(String url,String enc),其中enc是字符编码。

而且%必须编码为%25

public class DecodeTest 
{ 
    public static void main(String[] args) 
    { 

     String url="http://bitake.com/params/?attribute=3"; 

     String url1="http://search.bitake.com/params/?attr=48%25e6%2599%2582%25e9%2596%2593%25e3%2582%25"; 

     try 
     { 
     System.out.println(URLDecoder.decode(url,"UTF-8")); 
     System.out.println(URLDecoder.decode(url1, "UTF-8")); 
     } 
     catch (UnsupportedEncodingException e) 
     { 
     e.printStackTrace(); 
     } 
    } 
} 
+0

在这里我只是想为url1(重定向后URL)来解码网址1。 – anata

+0

对不起,我不明白你在问什么。 – JBuenoJr

+0

请再看一遍我的问题。我不擅长英语。 – anata