2013-02-28 18 views
2

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

<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> 

但这是启动一项活动,有没有什么办法启动我的服务(在后台默默地)?

回答

0

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