Android: Launch Shortcut picker - android

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

Related

Launcher that open the other launcher

I want to know if the user clicks on the Home button (like listen to Home button).
Because I saw that is there now way to do that, I tough about an idea.
Maybe if I will create a launcher I will be able to handle to Home button...
But since I don't want to really create a launcher, so I want to create a launcher, that opens the previous one.
How can I create such a launcher? Or is it possible to use BroadcaseReceiver to listen to Home button?
HOME button can not be monitored nor reacted to and there is no workaround.
As for the launcher:
First, you would need to fetch the ResolveInfo for the current launcher and keep its package name somewhere, like SharedPreferences.
Later, the user would have to accept your launcher as the default launcher. After that, you should make your launcher's onCreate() method's only job to create an intent which will open the previously saved package and then immediately call finish() on your launcher.
However, I am pretty sure you will stumble upon some problem along the way, as this is Android. Anyway, be my guest to try and post the result here, the concept is really interesting.

Give user choice of setting default home page

I'm looking for a way to present the user a choice of setting the home page programmatically.
What I want is for my app to ask the user to pick their choice every time it starts up. Is there a way to do this? Or is there a work around for this?
Thank you
The only thing you can do is bring up the home screen. If the user has not already chosen a default home screen, and there is more than one home screen installed on the device, the chooser will let the user choose a default. The user is welcome to not choose a default as well, as it is their device, not yours.

How can I update a home application without being asked to redefine the default home?

I have developed an application set as a home onto my Android device. On my device I set it as the default home application. That way, each time I click the home button, I am redirected to this app.
The problem I have is that I have to produce some updates. But when the app has been updated, the device ask to define the default home once anew.
I would like the update to be performed without the user having to define the default home again.
There isnt a way to do this. Each time your app is updated the user will have the opportunity to chose whether they want to keep it as the default home application. It is a means of Android showing a user he or she is in control of there device at all times.
If im wrong someone please correct me.

Android: How to control the home button

We're trying to provide an application to the mentally and physically handicapped daughter of my neighbor that let's her use an Android tablet as a Talker, i.e., she presses a few big buttons and the devices generates speech. The application is basically a WebView and an additional object in Javascript used to perform and control the speech generation, plus some logic to handle the orientation changes. Html files are generated offline for her specific layout of the talking items. We've also added some music playing and picture viewing facilities to make the device more appealing to her.
Problem is that the home button brings her back into the madness of the Android launcher screen, and that on the test device (Archos 70) the home button is not a physical button but rather shown on the touch screen itself, making it too easy to accidentally hit it.
So I'd like to return to the Android launcher only by pressing a sequence home, back, home with no other action in between.
Can I achieve this by making my application itself the launcher? How can I then get back to the original launcher upon the home, back, home sequence? It seems that this goes deep into the innards of Android, huh?
The only clue I found so far is Overriding Home button for a Car Home replacement app, but this is rated -1 and reported to work in the emulator only. Also I doubt if I could completely abandon the original launcher, as otherwise there is no access anymore to e.g. the USB mass device control to allow new HTML files to be downloaded, the application to be killed and restarted, and so forth.
I'm willing to go for a kludge as well. Maybe a background service could be started that would bring the application to the front again as necessary?
The Home button cannot be overriden. You can write an application that responds to the home intent (that's what a launcher does) but that's all.
Can I achieve this by making my application itself the launcher? How can I then get back to the original launcher upon the home, back, home sequence? It seems that this goes deep into the innards of Android, huh?
Yes. Not too deep into the
innards. You can manually start a launcher by specifying the component, note that this may vary from device to device and user to user, if you're just using this privately you could hard code it, but if you release it you must allow the user to specify their real home app.
/* This should come from a preference that let's the user select an activity that can handle the HOME intent */
String packageName = "com.android.launcher";
String packageClass = "com.android.launcher2.Launcher";
Intent home_intent = new Intent(Intent.ACTION_MAIN);
home_intent.addCategory(Intent.CATEGORY_HOME);
home_intent.setComponent(new ComponentName(packageName, packageClass));
home_intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
/* Here you should catch the exception when the launcher has been uninstalled, and let the user save themselves by opening the Market or an app list or something. Users sometimes use root apps to uninstall the system launcher, so your fake launcher is all that is left. Might as well give the poor user a hand. */
startActivity(home_intent);
Detecting home/back/home is a bit awkard because home won't come as a onKeyEvent but instead as a new intent. Simply long-pressing the back button then display a prompt is probably a safe/good approach.

Launch my Activity when any (or selected) Apps are launched

I'm developing a Learning Application. In it, I have an Activity where the user can select some applications from a list of all the applications installed on his device.
Now, I'd like to launch my Activity whenever the user launches any of the selected applications from the app list. Basically I'd like to override the selected Activity by my activity. Once the user complete's some task, the user should be returned to the previously clicked Application.
How do I "Capture" this 'Launching other applications' part? BroadcastReceivers? Any example would be highly helpful. I'd be very grateful if anyone points me in the right direction with reference links.
This is very similar to a Lock Apps Application. But in a very badly twisted kind of way.
I know I have to use a background service to monitor the user activity.
You don't intercept arbitrary application launches, if that's what you're after. Doing this silently goes against the Android (or any reasonable) security model.
What you can do is offer an alternative Home screen.
However, if you just have a list view of available applications, nothing stops you from defining custom behaviours within that list activity.

Categories

Resources