I was just wondering, is there any way I can make an android widget show up on a user's home screen when they install my application? Also, can I let them choose to create a widget from within my application?
Asked
Active
Viewed 5,596 times
6
-
Possible duplicate of [Binding AppWidgets to AppWidgetHost - Android](http://stackoverflow.com/questions/4258579/binding-appwidgets-to-appwidgethost-android) – rds Jun 30 '16 at 17:46
2 Answers
5
I was just wondering, is there any way I can make an android widget show up on a user's home screen when they install my application?
No, sorry. None of your code gets executed upon install.
Also, can I let them choose to create a widget from within my application?
No, sorry. Only the home screen can add app widgets to the home screen.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
Ok i agree with your answer but i am surprising how this app made this function work https://play.google.com/store/apps/details?id=com.cleanmaster.mguard – Hardik Apr 11 '14 at 06:27
-
it has a 1 tap boost function when click on icon in home screen here i already ask a question about smiler functionality may you answer this..? http://stackoverflow.com/questions/23004624/is-it-is-possible-to-make-android-app-launcher-icon-animated-when-i-click-on-it/23004676#23004676 – Hardik Apr 11 '14 at 06:29
-
@Hardik, I think, clean master not create any widget, rather it creates the shortcut of application – Kimmi Dhingra Apr 19 '16 at 06:51
-
@ErKimmiDhingra Yes Clean master creating shortcut of application but my question was how they animating shortcut icon. see my answer in above link – Hardik Apr 20 '16 at 03:48
-
1
Where is no way to get callback upon installation. But in Android O you can pin your widget on first launch of your application.
AppWidgetManager mAppWidgetManager =
context.getSystemService(AppWidgetManager.class);
AppWidgetProviderInfo myWidgetProviderInfo = new AppWidgetProviderInfo();
ComponentName myProvider = myWidgetProviderInfo.provider;
if (mAppWidgetManager.isRequestPinAppWidgetSupported()) {
// Create the PendingIntent object only if your app needs to be notified
// that the user allowed the widget to be pinned. Note that, if the pinning
// operation fails, your app isn't notified.
Intent pinnedWidgetCallbackIntent = new Intent( ... );
// Configure the intent so that your app's broadcast receiver gets
// the callback successfully. This callback receives the ID of the
// newly-pinned widget (EXTRA_APPWIDGET_ID).
PendingIntent successCallback = PendingIntent.createBroadcast(context, 0,
pinnedWidgetCallbackIntent);
mAppWidgetManager.requestPinAppWidget(myProvider, null,
successCallback.getIntentSender());
}
Also check out Google official documentation

HeyAlex
- 1,666
- 1
- 13
- 31