问题
I am writing my android application, which I want to define a custom URI scheme, so that user can go to my app by typing a URI in browser, like: myapps://cate=1&id=3
I successfully implemented this in my apps, but I discover that for some device, the browser treat the link differently.
In my HTC Flyer, it opens my app correctly, but in Samsung Galaxy Ace, the browser translates the link to myapps%3A%2F%2Fcate=1%26id=3, which is encoded, and it just google the "myapps://cate=1&id=3" for me instead of open the app.
I define the intent filter in the manifest like this:
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="myapps"/>
</intent-filter>
Any help on this issue? thanks
EDITED
I just looked at the source code of android browser, it defined what scheme it accepts:
protected static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile(
"(?i)" + // switch on case insensitive matching
"(" + // begin group for schema
"(?:http|https|file):\\/\\/" +
"|(?:inline|data|about|content|javascript):" +
")" +
"(.*)" );
Now I understand why custom scheme won't work! Any apps should only capture schemes: http,https,file,inline,data,about,content,javascript.
回答1:
Why does it have to be a custom uri?
I'd try it with a standard URL and then I'd define a broadcast receiver for it.
That's essentially how http://youtube.com or http://maps.google.com work I think. Just try typing those two URLs in your Android browser of your Galaxy Ace.
来源:https://stackoverflow.com/questions/8463794/android-custom-uri-scheme-incorrectly-encoded-when-type-in-browser