Hi All,
I'm having some strange behavior of wakeup alarms scheduled by
AlarmManager in Motorola Milestone (Droid in US). The thing is that
they don't wake the device as they should. The same piece of code
works fine in Samsung Galaxy and the alarms are fired as they should
fire. In Milesstone when the device is in sleep no alarms are fired
but all the alarms are fired at once when the device wakes up. I also
found out that Milestone doesn't have the /proc/wakelocks file to
check the wake lock info but I'm not sure if that has something to do
with the problem. For this scenario there is no reason to acquire a
wakelock because the AlarmManager acquires it automatically for
lifetime of the OnAlarmReceive. I found some other threads about the
same problem in Droid/Milestone, but does anybody have an idea what is
the problem and is there anyway to solve it.
This is the code that I'm using to test this.
/**
* Broadcast receiver for the device boot
*
*/
public class OnBootReceive extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, OnAlarmReceive.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
AlarmManager m =
(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
m.setRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis()
+10000, 5*60*1000, pi);
}
}
/**
* The alarm receiver
*
**/
public class OnAlarmReceive extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("AlarmTester", "Alarm fired " + new Date());
File log=new File(Environment.getExternalStorageDirectory(),
"AlarmTesterLog.txt");
try {
BufferedWriter out=new BufferedWriter(new
FileWriter(log.getAbsolutePath(), log.exists()));
out.write("Alarm fired " + new Date().toString());
out.write("\n");
out.close();
}
catch (IOException e) {
Log.e("AppService", "Exception appending to log file",
e);
}
}
}
-Mika
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en