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.
Related
According to Android behavior when user takes an app to background by pressing home button, on launcher icon tap the app will resume from where it went to background. I want a different behavior in my app, i want to relaunch the launcher activity whenever user taps on the launcher icon, no matter the app is in background or not.
Any suggestions?
just set this in your launcher activity
android:clearTaskOnLaunch="true"
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?
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?
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.
I want to hide my app from main menu, when user want to, s/he can see their app.
To hide the app I've removed the launcher category, and for now the app get hidden but now I don't understand how can the user launch the app. I've read somewhere that using a key combination (on the DialerPad) one can show the main screen of activity. How is this done?
Any other ideas of launcher an app when a launcher is not present?
Yes you can hide your application icon but only on rooted devices or system signed apps.....the solution will be to first disable your application using shell command pm disable com.yourapppackagename and then enable it back using **pm enable com.yourapppackagename** this will first disable your app removing app icon from device and then enabling back your app will bring back the app icon only in device menu and not on homescreen. if you want to disable and then enable on user choice then you may create a toggle button such as when off then disable your app and when on then enable your app.It will definatly work i have already worked on something similar