I have a big problem with my app for serveral days now. I appologize
if my english is not so native in advance. I implemented an
AlarmManager to give the user of my app the option to start a certain
service at any time of the current or the next day. So e.g. the user
might choose to set the time for my service to tomorrow at 08:00 a.m.
and then starts the service.

The alarm manager should now wait the calculated time from now till
the chosen time (i calculated the time also manually and it is
correct!) and then start the service. My problem now is that sometimes
the alarmmanager is starting my service and somtimes not. It seems
that if it has to wait for lets say more than 4 hours it is not
working any more and my service is not called. I have set all
neccessary permission otherwise it would not work at all. You can have
a look at the code of the alarmmanager below:

someIntent = new Intent("START_SERVICE");
AlarmManager alarams ;

alarmIntent = PendingIntent.getBroadcast(MainActivity.this, 0,
someIntent, PendingIntent.FLAG_CANCEL_CURRENT);
alarams = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarams.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+delay,
alarmIntent);
The broadcast receiver is implemented like this (and it is
registered!):

alarmReceiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {

                Intent myIntent = new Intent(MainActivity.this,
MyService.class);
                startService(myIntent);
            }
        };

I read smth. about the WAKE_LOCK and that my Service might not be
called anymore before the phone goes into sleep mode after the
broadcast receiver is being called. Can this be the reason? I really
hope you can help me!!!!

Best Regards
eMu

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to