从 URL 启动活动
我试图在用户浏览到某个网址时启动我的应用程序。我找到了一些示例,它们在清单中都有相同的内容,但它对我不起作用。我已将意图过滤器放在活动和接收器下。
这是我的清单片段:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.urbandictionary.com" android:scheme="http"></data>
</intent-filter>
当在 Activity 下时,我尝试使用 onNewIntent,当它在 Receiver 下时,我尝试使用 onReceiveIntent,两者都通过简单的 Log.i 调用来查看它是否触发。我运气不太好。
I am trying to have my application launch when the user browses to a certain url. I have found a few examples and they all have the same things in the manifests but it's not working for me. I have put the intent-filter under an Activity as well as a Receiver.
Here is my manifest snippet:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.urbandictionary.com" android:scheme="http"></data>
</intent-filter>
When under the Activity, I tried using onNewIntent and when it was under a Receiver, I tried using onReceiveIntent, both with a simple Log.i call to see if it fired or not. I am not having much luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在我的manifest.xml 文件中使用它:
这将启动SomeName 活动。我不在 android:host 部分使用 www 也许这会有所作为。
当活动启动时,您可以使用(例如)获取 .com 后面的数据:
编辑:如果您不希望能够从活动中检查主机,请使用以下方法:
I use this in my manifest.xml file:
This will start activity SomeName. I don't use www in the android:host part maybe that will make a difference.
When the activity starts you can get the data that's behind the .com using (for example):
Edit: If you wan't to be able to check the host from within the activity, use this method: