android global hotkey
How to start your activity开发者_运维问答 on pressing a global hotkey on android? It is possible, see Button Shortcut app.
Here is the solution for the 'search' button:
<intent-filter>
<action android:name="android.intent.action.SEARCH_LONG_PRESS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Just for the archive:
This (alone) does not help:
<uses-permission android:name="android.permission.GLOBAL_SEARCH" />
<activity android:name=".VoiceActions"
android:label="@string/app_name">
<!-- This must be higher than the default priority (0), which
is what GoogleSearch uses. -->
<intent-filter android:priority="500">
<action android:name="android.search.action.GLOBAL_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<meta-data android:name="android.app.default_searchable"
android:value=".VoiceActions" />
</application>
精彩评论