Unset default home screen from code - android

I'm trying to unset the default home screen programatically. My app is defined as home in manifest but if the user select the phone home screen as default (in the dialog to select the home screen) i cannot set my app as home again.
If the user select my app as home screen as default (with the checkbox "set as default") i have only to do:
clearPackagePreferredActivities("MypackageApp"); //from packagemanager
Then the selector appears again. But I don't know how to do for the dialog to select the current home screen appears again (when the user select the phone home screen as default) . I have tryed this:
clearPackagePreferredActivities("com.android.launcher"); //from packagemanager
But i obtain an error:
java.lang.security.exception Neither user * nor current process has android.permission.SET_PREFERRED_APPLICATIONS. But i have defined this permission in my manifest app.

I'm trying to unset the default home screen programatically.
Fortunately, this is not possible, for obvious security reasons.
My app is defined as home in manifest but if the user select the phone home screen as default (in the dialog to select the home screen) i cannot set my app as home again.
The user who switched back to a different home screen would consider this to be a very good thing.
But i have defined this permission in my manifest app.
You can only hold that permission if your application is signed by the same signing key as was used to sign the firmware.

Related

Disable home button and recent apps button in android application

I need to disable home button and recent apps button in my application since the activity opened which takes information is required and cannot leave empty
You can look for kiosk mode but that will require special permission (device admin permission) to activate.
you can also try "startLockTask()" in activity onCreate that will create a pinned screen

Control Launcher option in android

I have created an app for visually impaired. When the user clicks on Physical Home button I am getting the launcher dialog box working perfectly fine.
Instead of inbuilt dialog box. I would like to get my activity screen which has the list of launchers so that user can select and open any launcher according the requirement.
For e.g.
If the user has two launcher
Launcher (Default)
MyApp launcher
On myactivity screen it should show up launcher and myApp and user should able select anything required.
Is this possible? if so how? Can somebody direct me to that page as a start?
Thanks!
When the user presses the home button, the system is attempting to fulfil the android.intent.category.HOME intent. The dialog pop up is there when there is no user preference, the system will always have control of this UI.
What you could do is fulfil this intent yourself, and be the default launcher - even if your launcher's action is to provide the means to launch another launcher?

Home screen component name

I am developing simple home screen application. So when i press home button i can
choose between native and mine home screen app. The problem is: if i set my app as default
home screen application when i restart phone i can't enter native home screen app
because it has never started so my app stands on top off stack. How can i enter
native home screen app when i restart phone if mine is default home screen app?
I have idea:
On boot, i can check the calling intent - if it contains the Home category, i will call native home screen app. Something like this:
Intent creatingIntent = getIntent();
if (creatingIntent.hasCategory(Intent.CATEGORY_HOME))
{
creatingIntent.setPackage("com.android.launcher");
creatingIntent.setComponent(new ComponentName
("com.android.launcher",
"com.android.launcher2.Launcher"));
startActivity(creatingIntent);
finish();
}
But the problem is i don't know how can i get Component name for native home screen application, can someone help?
The goal of an home app (=launcher) is to replace the native launcher, it's weird to force the cohabitation of 2 launchers. But if you success to do something like that, when you press on the home button it will launch also the Native launcher.
To answer your question, the native launcher depends of the target device. Example : samsung doesn't use the same launcher than google, so components name will be different.
Have you tried to do a broadcast receiver which launch your app at start up ? With that, you don't have to put your apps as default home app, so you conserve the choice when you press on the Home button. However, it's not a solution if a user choose your app as default app.
Maybe you can look here How to use customized screen instead of default start screen in Android?

Reset default launcher when app is closed

I have created a children's app that has a child lock using a custom launcher, however I have one small problem. When the app is closed and the home button is pressed the dialog to select the default launcher is displayed. Is there are way to reset the default launcher when the app is closed?
You cannot make any particular app be the default. However, you could use PackageManager and setComponentEnabledSetting(), to disable your activity that has the HOME category. Re-enable that when the user wants to have the choice of using your home screen again.

Android Application Dashboard with pin/password to exit

Here I'm trying to implement an Android Application Dashboard where user press the exit button to be asked for a pin or a password to exit the application, or go to the home page.
You can not control the behaviour of the Home key whenever it is pressed the home screen will be shown however you can bring your application in foreground as soon as Home screen is shown.
When exit button is pressed then you can ask user to enter the credentials. you can do this either in alert dialog with custom layout or taking user to other activity.
You can use SharedPreference to store the credentials if the data is limited else SQlite.
That's what you are asking ?

Categories

Resources