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

Adam Arold picture Adam Arold · Apr 19, 2013 · Viewed 21.5k times · Source

I'm writing an application which should be able to add widgets (just text boxes) to the home screen of the user's phone when the user instructs my app to do so. How can I do such a thing?

I know that I can add an app widget but how about adding more?

Answer

stinepike picture stinepike · Apr 19, 2013

It is not possible from a app to place a widget in the home screen. Only the home screen can add app widgets to the home screen.

similar links link1, link2, link3

But you can offer user to pick widget from widgetpicker.

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