Widget - Install automatically through the application

0

I would like to create a feature in the App to automatically add the Widget of the application.

When the user clicks a button, automatically inserts Widget into the home screen.

Is it possible?

    
asked by anonymous 28.06.2016 / 02:50

1 answer

0

You can not enter the widget automatically, you can open the widget selection for the user to choose from by clicking the button:

Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetID);
startActivityForResult(pickIntent, KEY_CODE);

It looks like it's going to go against some Android policies as this opens up several security breaches without the user's consent.

More information on the links below:

How to add a widget to the Android home screen from my app?

Binding AppWidgets to AppWidgetHost - Android

    
28.06.2016 / 04:09