Im working on lockscreen in android How we can disable navigation soft buttons, have tried all the ways, systemoverlay but its doesnt work, on pressing home button its kill the service and activity.
back button can be controlled by overriding the onbackpressed() method.
Homebutton can controlled by making your application a launch.
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>
above code shows intentfilter for creating an launcher. For more info google about making an app a launcher app.
- the recent app button can be controlled by bringing your app by using moveTaskToFront in your onpause function of the activity(This works only in and after honeycomb).
add the below code in your
ActivityManager activityManager = (ActivityManager) getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
You cannot override the home button on version 4.0+ This is made for security purpose.
However, you can create a service that shows a window that handles all touch events. Take a look at the best answer at this question
You may also look at some 'App Lock' applications, cause they use the same technique.
But this way doesn't work completely. On some devices, it is possible to open NotificationBar above your service.
There is also another way, and it can override the home button, but does not work for Recent.
You should create an application that will be considered on device as a Launcher Application, but will look like a Locker. Now, when the user unlocks the device, your application starts the actual Launcher Application.
© 2022 - 2024 — McMap. All rights reserved.