2013-10-21 36 views
1

一%2F我用這個代碼:Uri.fromParts讓我在Android模擬器

Intent i = new Intent(Intent.ACTION_VIEW); 
i.setData(Uri.fromParts("http", "//google.com/", "")); //fromParts is ok b/c the scheme is different 
startActivity(i); 

但對Android模擬器瀏覽器中我得到這個地址:

的http:%2F %2Fgoogle.com

這是爲什麼?如何解決?

回答

3

sourceUri.fromParts()構建一個OpaqueUriOpaqueUri.toString() URL編碼的特定方案的部分,改變/%2F

這是一個documented feature

進行編碼,這意味着這種方法不能被用於創建分層URI的SSP。

要獲得分層URI你想,使用

Uri.parse("http://google.com/") 

或使用Uri.Builder