Overriding Search Long Press

谁说我不能喝 提交于 2019-12-25 08:15:34

问题


On many Android phones, when a user long presses the Search button, it launches the Google Voice Search intent. How can override this feature across the entire system, not just overriding Search button long presses from an activity? More specifically, how can I add my app to be the same type of intent as Google Voice Search so that it shows up as a "Choose Application" option when the Search button is long pressed. Thanks a lot!


回答1:


Try using "android.intent.action.SEARCH_LONG_PRESS" as your action with the category as "android.intent.category.DEFAULT" under your intent-filters in your AndroidManifest.xml

<application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".YourActivityName" 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>
        </activity>

    </application>


来源:https://stackoverflow.com/questions/7922628/overriding-search-long-press

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!