Control Launcher option in android - 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?

Related

Android: Create activity on home screen with user's permission

I have created a widget and it's working properly. If the user wants, he can add my application's widget on the home screen. However, what I want is, for my own code to "put the widget on the homescreen" with user's permission; because the widget is the most important part of the application, without which it'd be useless.
I'd like to implement something like the following:
a. For example, when an application tries to start bluetooth, the system tells the user "Ok dude, this application wants to turn on bluetooth, do you want to allow this?". Similarly, "Application X is trying to create a home screen widget, do you want to allow it?".
or
b. When you try to add a widget manually to homescreen, the system shows a list of available widgets that you can choose from, and then you select the one you want. Is there some way where I can call this "list of widgets activity" from my code, when my application starts up?
Thanks for the suggestions!

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.

How to create a shortcut for widget?

I have created the widget, but this widget does not show directly on the home screen, I want it to be displayed directly on the home screen, immediately after the application is deployed, like a shortcut, and clicking on the shortcut widget will go to the application
Can someone suggest me?
Thanks
I want it to be displayed directly on the home screen, immediately after the application is deployed
You cannot run any code at the time the user installs your application. You must wait for them to launch it, or in the case of a home screen widget you must wait for them to explicitly place it on the home screen.
You have to add an intent line to your manifest that exposes the action you want to do through a shortcut.
see: http://android-developers.blogspot.sg/2009/11/integrating-application-with-intents.html?m=1

Android: Launch Shortcut picker

I have looked everywhere for something related to this. I want to launch a shortcut, based on the shortcuts installed on a device.
A simple way of putting this is my user selects one of his shortcuts through my application. When the user initiates the shortcut through my app, it will perform the exact same thing as if he/she is on the home screen and selects the shortcut.
I can do this individually with the system shortcuts, but I want to have more flexibility for other shortcuts installed on the device.
So basically, I need to figure out how to bring up the shortcut picker (the same list that appears by long pressing a home screen and selecting shortcuts), get the intent to launch that shortcut and store that within my application data for use later. I don't want to actually initiate the shortcut when the user selects it, I just want to remember it for later.
Any help with this would be greatly appreciated :)
I think you are looking for this: https://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT

Categories

Resources