Android服务接收/拦截“home long pressed”事件(类似于“Home Button Launcher”)

时间:2015-02-22 19:37:47

标签: android android-intent android-activity android-service android-broadcast

我正在开发一个需要接收/拦截长按主页按钮事件的应用程序。我相信这个功能可以通过广播接收器意图过滤器实现,因为现有的应用程序称为“Home Button Launcher(https://play.google.com/store/apps/details?id=com.dynamicg.homebuttonlauncher&hl=en)”,但我找不到任何有关如何执行此操作的相关讨论。

安装此应用程序并长按主页按钮(3~5秒)后,Android会要求用户选择需要启动的应用程序(默认Google搜索或已安装的主页按钮启动器),如https://play.google.com/store/apps/details?id=com.dynamicg.homebuttonlauncher&hl=en

所示

有很多帖子讨论如何在应用程序中获取主页按钮事件,以了解用户何时关闭其应用程序,但没有关于如何使用此广播事件的帖子。

有人知道我如何接收/拦截此事件,就像主页按钮启动器一样吗?

1 个答案:

答案 0 :(得分:0)

感谢Selvin发布的提醒。唯一的办法是在清单文件中添加此意图过滤器:

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