Reputation: 123
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
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