Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restrict Android Widget to one instance per device

How could I restrict Android widgets in a way that only one instance can be created by the user at all times?

A possible way is to store a SharedPreference including a counter variable and crash, if the count is 1, but obviously I'm not in favor of that solution. ;-)

like image 326
Sebastian Roth Avatar asked Dec 29 '10 08:12

Sebastian Roth


1 Answers

How could I restrict Android widgets in a way that only one instance can be created by the user at all times?

You can't.

However, just because the user asks for multiple instances of your app widget does not mean you have to manage separate data for each. Just ignore the IDs and use the updateAppWidget() method that does not take any IDs.

like image 185
CommonsWare Avatar answered Sep 29 '22 01:09

CommonsWare