Android - AppWidgets, AlarmManager and AsyncTask -
I do not have much luck with updating an app widget AlarmManager
Generated broadcast here What to do:
AlarmManager alarms = (AlarmManager) to start
AppWidgetProvider # onEnabled
at alarmmanager
Reference. GetSystemService (event .ALARM_SERVICE); Alarms.setRepeating (AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedReautime (), 60000, pendingIntent);
I also define the broadcast receiver which just listens for updates removed by the alarm manager
. When the update is removed, the code runs AsyncTask
that creates a network call when AsyncTask
is completed ( onPostExecute
), then To update the widget (s) it uses pre-charged charge of AppWidgetManager
. All of this really works well in logs until I get the message "process com.foo.myapp (pid 12345)"
, after which alarm manager
Never solves any other updates. / P>
Do I need to check some types of alarms that will restart? For example, when the user accesses the original app's widget? How can I ensure that I can complete the long lasting work and return to my app if I die in the middle of the request?
When a update is removed, the code runs asyncTask which makes a network call .
If it is inside BroadcastReceiver
, then it will not work, you can not safely disconnect from BroadcastReiveriver
, and < Code> AsyncTask can effectively use a thread to do your job asynchronously.
Instead, you have long been running Broadcast Receiver
. Work for
Comments
Post a Comment