bogdanmogo
bogdanmogo

Reputation: 123

How can I add a Home AppWidget from mainActivity?

I have the mainActivity class:

....
final Button addWidgetBtn = (Button) findViewById(R.id.addWidget);

addWidgetBtn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
    //on button click add Home Widget       

}

});
....

The main.xml view:

....
<Button android:id="@+id/addWidget" android:text="Add widget"/>
....

The FlowerForYouWidget.java class:

public class FlowerForYouWidget extends AppWidgetProvider {
...
}

When I click on the addWidget button I want to add a Home Widget.

Upvotes: 0

Views: 81

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006664

There is no support for adding an app widget this way. Users can add an app widget via the home screen.

Upvotes: 1

Related Questions