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
Related
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.
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!
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 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