Monday, June 6, 2011

Re: [android-developers] Background services and notifications.

Hi,

I updated my app to set a repeating alarm that starts the service every 5 mins.
I checked this and it fired every 5 mins throughout the day without missing.

The service OnStartCommand code runs which calls getLastKnownLocation and triggers the Activity to update through a listener if its running.
I also added a startActivity to open my Activity it the requirement is met.
This works OK if the phone is awake but not if the phone is asleep.
I changed it to an alarm, fired immediately with my Activity as the PendingIntent.

I use:-
Intent i = new Intent(getBaseContext(), Finder.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mAlarmSender = PendingIntent.getActivity(getBaseContext(), 0, i, PendingIntent.FLAG_ONE_SHOT);
calendar.add(Calendar.SECOND, 1);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), mAlarmSender);

The log says
Starting activity: Intent{flg=0x10000004 cmp=edam.Finder/.Finder (has extras)}
Something wrong here, didn't expect edam.Finder to be paused
onResume
onPause

Then it looks like it returns to the service running every 5 mins as expected.
The phone never wakes up.

Any ideas?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment