Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从html链接启动Android服务?_Android_Html_Service - Fatal编程技术网

如何从html链接启动Android服务?

如何从html链接启动Android服务?,android,html,service,Android,Html,Service,我知道有一种方法可以从html链接url(例如单击电子邮件中的url链接)启动应用程序(活动),如下所示:(www.youtube.com只是一个例子,我有自己的主机) 但这是在启动一项活动,有没有办法启动我的服务(在后台静默) 是的。使用该意图过滤器注册活动,从活动的onCreate启动服务,然后调用finish()。通过在onCreate完成之前调用finish(),用户永远不会看到该活动 <intent-filter> <action android:name=

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



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

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

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