I have this problem that I’m registering my Broadcast receiver for AlarmManager in the manifest. And I’m scheduling it in my Activity through pending Intent.
AlarmManager alarmMgr = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
PendingIntent pendingIntent =PendingIntent.getBroadcast(this, 0, new Intent(this, AlarmReciever.class),PendingIntent.FLAG_CANCEL_CURRENT);
alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, Constants.ALARM_TRIGGER_AT_TIME,Constants.ALARM_INTERVAL, pendingIntent);
But in my receiver class I’m doing some network updates using AlarmManager…which I’m saving in a database. I have a ListAdapter in the activity and need to notifydatasetChanged…for which I need an instance of my activity.
How to get it? Basically I want to update my UI at least when my app is visible.
I got the answer..For refreshing my activity which is visible
If activity visible it will call the OnNewIntent() in your code and thus onResume() where you can update Your UI..