Handling Home button android for developing lock screen

大憨熊 提交于 2019-12-24 12:29:40

问题


I am developing lock screen application for that i need to disable the home button. some one told to me kept in the manifest as category as default, home but when ever device boot completed my activity launches but not finishing.because I my application is home How to handle the Home button.How Go locker application handled Home button

 <intent-filter>
             <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.DEFAULT" />

        </intent-filter>

please give me a proper suggestion i would very thankful to you.


回答1:


You need to add:

<category android:name="android.intent.category.LAUNCHER" />

so your full intent-filter section looks like this:

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

Not this still won't FORCE the app to run at boot. This will just add it to the list of launchers. It will only launch at boot if the user chooses it as their default launcher.

If you want to run an activity at launch, you can register a broadcast receiver to handle the ON_BOOT_COMPLETED action, but think very carefully before doing so; is this what all users of your app would want?



来源:https://stackoverflow.com/questions/22625687/handling-home-button-android-for-developing-lock-screen

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