javaandroidandroid-widgethomescreen

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


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?


Solution

  • 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);