I want to open the launcher's widget picker (for example, the one we get when we long press on home screen) from my Activity. What I want to achieve is, I want to take the user to my widget so that there are more chances that he will consider adding it.
Programmatically adding the widget to home screen will be the best case. But, because that is not possible, I want to go as closer as possible to make user add the widget.
I tried the following but that only opens a dialog (not the launcher's) with all the widgets and by selecting one nothing happens.
Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0);
startActivityForResult(pickIntent, 1234);
How to make this work? Any suggestions on this scenario are much appreciated.
First, long-press on the home screen and then swipe up from the bottom of the screen to access "Widgets." Then Nova Actions > App Drawer. This will add an app drawer button to the home screen which you can then place in the dock.
Find a Space First, touch and hold an open space on your home screen. You'll see an option at the bottom of the screen to view the widgets drawer. Where they dwell until summoned for duty.
Picker is a widget showing multiple customized PickerColumn s. The PickerColumns are initialized in setColumns . Call setColumnAt if the column value range or labels change. Call setColumnValue to update the current value of PickerColumn.
It's possible to pin widget to homescreen (official doc) on API 26+:
AppWidgetManager mAppWidgetManager =
context.getSystemService(AppWidgetManager.class);
AppWidgetProviderInfo myWidgetProviderInfo = new AppWidgetProviderInfo();
ComponentName myProvider = myWidgetProviderInfo.provider;
if (mAppWidgetManager.isRequestPinAppWidgetSupported()) {
Intent pinnedWidgetCallbackIntent = new Intent( ... );
PendingIntent successCallback = PendingIntent.createBroadcast(context, 0,pinnedWidgetCallbackIntent);
mAppWidgetManager.requestPinAppWidget(myProvider, null,
successCallback.getIntentSender());
}
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