Reputation: 4472
I am newbie in android programming. I like to create a widget to update network status such as signal level, operator details. Can i update these data on an interval of a second. It is possible in widget. If yes kindly provide a solution to do it.
thanks
Upvotes: 1
Views: 78
Reputation: 9730
You can't do this natively because android:updatePeriodMillis
is restricted to a minimum period of 30 minutes.
You can bypass this limit by adding a service that will update your widget to the AlarmManager(which does support intervals less than 30 minutes):
final Intent _intent = new Intent(context, MyUpdateService.class);
final PendingIntent pending = PendingIntent.getService(context, 0, _intent, 0);
final AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm.cancel(pending);
long interval = 60000;
alarm.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),interval, pending)
Upvotes: 1