Hello, I have been working on the following issue for weeks now and I cannot find the problem nor can I find an answer anywhere and hope someone on this list can help. I tried posting to this mailing list five days ago but got no response and I am still searching so I am going to try and post again.
I am using an alarm manager with a broadcast receiver. The problem is that it works fine half of the time, namely when the device is attached via USB or when I set the alarm for just a few minutes from now. When the device however falls asleep it seems the alarms are either being lost or fire up when I power on the device, late. The problem is described here http://stackoverflow.com/questions/5262641/can-i-wake-up-my-android-when-it-is-not-plugged-in-and-sleeping with no concrete solution. I have been experiencing this problem on a brand new P690 Optimus Net running Android 2.3.4 and I have written my app for version 2.3.3 (version 10). I don't know where the probelm is. I am really really lost on this one and don't know what to do. As the poster describes, even if I power the device off and then turn it on things work (in fact I respond to the android.permission.RECEIVE_BOOT_COMPLETED and set the alarm there just fine it seems, so that is not the issue). I tried using a WakeLock as shown below, just in case my activity was falling asleep when the broadcast receiver was launching it but no luck. Any help would be greatly appreciated as I really need to be able to rely on the timer to wake up my app when it expires, Thanks a lot, John Goche import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.util.Log; public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d("AlarmReceiver", "received"); // retrieve database handle Log.d("AlarmReceiver", "retrieving database handle."); DB db = DB.db(context); // retrieve data from database Log.d("AlarmReceiver", "retrieving data."); Globals.data = db.getData(); // reset alarms Log.d("AlarmReceiver", "Calling alarm setter..."); AlarmSetter.doSetupAlarm(context); Log.d("AlarmReceiver", "Done."); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); wl.acquire(); // start new intent Intent i = new Intent(context, AlarmExpiredActivity.class); i.putExtra("alarmMessages", intent.getBundleExtra("alarmMessages")); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); wl.release(); } private static final String TAG = "AlarmReceiver"; } class AlarmSetter { public static void doSetupAlarm(Context ctx) { Log.d("AlarmSetter", "doSetupAlarm called."); // ... pendingIntent = PendingIntent.getBroadcast(ctx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent); } } private static PendingIntent pendingIntent; } -- 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