在服务中意向筛选意向

2023-09-07 13:03:51 作者:网名不要太长像我这样就好

我有我的清单文件中的以下内容:

I have the following inside my manifest file:

<service android:name=".Rotate" 
    android:enabled="true"
    android:label="@string/app_name"> 

    <intent-filter>
        <action android:name="android.intent.action.SEARCH_LONG_PRESS" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</service>

然而,按下搜索键不激活 SEARCH_LONG_ $ P $干燥综合征了。之前我换成&LT;活性GT;服务&GT; 用它来显示两个选择,当长pressing 与&LT搜索键,一个是我的应用程序,另一个是谷歌语音搜索...现在它只是谷歌语音搜索。

However the holding down the search key doesn't activate SEARCH_LONG_PRESS anymore. Before I replaced <activity> with <service> it use to show two options when long pressing the search key, one was my app the other was Google Voice Search... now it's just Google Voice Search.

推荐答案

这是因为 SEARCH_LONG_ $ P $干燥综合征不用于服务。它是用于活动。每次使用意图系统(的 startActivity() startService() sendBroadcast())是相互独立的。你可以不必 startActivity服务响应(),例如

That is because SEARCH_LONG_PRESS is not used for services. It is used for activities. Each use of the Intent system (startActivity(), startService(), sendBroadcast()) is independent of the others. You cannot have a service respond to startActivity(), for example.

 
精彩推荐
图片推荐