I have developed android widget app and its working fine. Now my client asks that, when the user installed this app, it automatically needs to place on homescreen top position. How to do this? please help me.
Select Apps and widgets that you want to add to the home screen. Make sure you switch to Widgets on the screen that is opening up. Find the Multicon widgets and select the one you want to use by holding down your finger on it and moving it to the location you want it to be displayed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AppWidgetManager mAppWidgetManager = getSystemService(AppWidgetManager.class);
ComponentName myProvider = new ComponentName(AddWidgetActivity.this, AppWidgetSmall.class);
Bundle b = new Bundle();
b.putString("ggg", "ggg");
if (mAppWidgetManager.isRequestPinAppWidgetSupported()) {
Intent pinnedWidgetCallbackIntent = new Intent(AddWidgetActivity.this, AppWidgetSmall.class);
PendingIntent successCallback = PendingIntent.getBroadcast(AddWidgetActivity.this, 0,
pinnedWidgetCallbackIntent, 0);
mAppWidgetManager.requestPinAppWidget(myProvider, b, successCallback);
}
}
As of Android O, In your app, you can create a request for the system to pin a widget onto a supported launcher.
See the bottom part of this page: https://developer.android.com/preview/features/pinning-shortcuts-widgets.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With