问题
hey i want to make an Application which will start when the phone will start, which i am able to do so but my problem is to disable the "Home Button" & "Back Button" on start up an it should only be enable when i click an button on my activity which will be the home screen on start up, please help me out..
回答1:
You have to make an intent-filter
for BOOT_COMPLETED
. You can get the tutorials from here and here
To disable HOME and BACK
Lets se... If your app is running and visible to user then you can do that by using the following code
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)
&& event.getRepeatCount() == 0)
{
onBackPressed();
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onBackPressed() {
// Do nothing
return;
}
But if your app is not running then it is not possible for you to do that how ever you can make your custom launcher in that wey you can decide weather to show the screen or not
OR
You can disable the home key check here
来源:https://stackoverflow.com/questions/13282544/android-to-lock-the-home-button-and-back-button-in-android