Created
December 11, 2016 17:15
-
-
Save yerenutku/63baf7f0c8231d75c70a9b550f24052b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UpdatingWidget extends AppWidgetProvider { | |
private PendingIntent service; | |
@Override | |
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { | |
final AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); | |
final Intent i = new Intent(context, UpdateService.class); | |
if (service == null) { | |
service = PendingIntent.getService(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); | |
} | |
manager.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(), 60000, service); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment