【问题标题】:Intent-Filter within a Service服务中的意图过滤器
【发布时间】:2010-10-31 11:02:24
【问题描述】:

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

<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_PRESS。在我将 &lt;activity&gt; 替换为 &lt;service&gt; 之前,它会在长按搜索键时显示两个选项,一个是我的应用,另一个是 Google 语音搜索……现在它只是 Google 语音搜索。

【问题讨论】:

    标签: android service intentfilter


    【解决方案1】:

    那是因为SEARCH_LONG_PRESS 不用于服务。它用于活动。 Intent 系统(startActivity()、startService()、sendBroadcast())的每次使用都独立于其他系统。例如,您不能让服务响应startActivity()。

    【讨论】:

      猜你喜欢
      • 2017-02-24
      • 1970-01-01
      • 2012-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-04
      • 2014-10-19
      • 1970-01-01
      相关资源
      最近更新 更多