2

我知道有一种方法可以从 html 链接 url(例如单击电子邮件中的 url 链接)启动应用程序(活动),如下所示:(www.youtube.com 只是一个示例,我有自己的主机)

<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.youtube.com" android:scheme="http"></data>
</intent-filter>

但这正在启动一项活动,有什么方法可以启动我的服务(在后台静默)?

4

1 回答 1

0

是的。使用该意图过滤器注册一个活动,从活动的 onCreate 启动服务,然后调用 finish()。通过在 onCreate 完成之前调用 finish(),该活动不应该对用户可见。

于 2013-02-28T21:11:57.990 回答