开发者

start activity from browser

Im trying to register a protocol in my app whereby a url executed in the android browser will launch my activity, all the examples Ive seen on the web say to add an Intent Filter on my activity such as

<activity android:name=".UrlActivity">

<intent-filter> 
<action android:na开发者_运维技巧me="android.intent.action.View"/> 
<category android:name="android.intent.category.DEFAULT"/> 
<category android:name="android.intent.category.BROWSABLE"/>  
<data android:scheme="myscheme" android:host="myhost"/> 
</intent-filter>
</activity>`

but this doesnt seem to be enough to get the Android OS to launch my activity... Is there anyone who could tell me if there is something Im missing?

Thanks


Try removing theandroid:host part, but retain the android:scheme attribute.

Also check logcat for any errors or warnings.


The URL has to be made available as a hyperlink on a page for the user to tap. Entering the URL in a browser on your device will not work. This resolved the problem for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜