Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid AlarmManager not waking phone up
    primarykey
    data
    text
    <p>I want an activity to be displayed at a certain time. For this, I am using AlarmManager. It works fine when the device is awake, but it doesn't wake it up if it's asleep.</p> <p>My code for setting the alarm:</p> <pre><code>Calendar alarmTime = Calendar.getInstance(); alarmTime.set(Calendar.HOUR_OF_DAY, alarm.hour); alarmTime.set(Calendar.MINUTE, alarm.minute); alarmTime.set(Calendar.SECOND, 0); if (alarmTime.before(now)) alarmTime.add(Calendar.DAY_OF_MONTH, 1); Intent intent = new Intent(ctxt, AlarmReceiver.class); intent.putExtra("alarm", alarm); PendingIntent sender = PendingIntent.getBroadcast(ctxt, alarm.id, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime.getTimeInMillis(), sender); </code></pre> <p>My broadcast receiver:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { try { Bundle bundle = intent.getExtras(); final Alarm alarm = (Alarm) bundle.getSerializable("alarm"); Intent newIntent; if (alarm.type.equals("regular")) { newIntent = new Intent(context, RegularAlarmActivity.class); } else if (alarm.type.equals("password")) { newIntent = new Intent(context, PasswordAlarmActivity.class); } else if (alarm.type.equals("movement")) { newIntent = new Intent(context, MovementAlarmActivity.class); } else { throw new Exception("Unknown alarm type"); } newIntent.putExtra("alarm", alarm); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(newIntent); } catch (Exception e) { Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show(); Log.e("AlarmReceiver", Log.getStackTraceString(e)); } } </code></pre> <p>This code doesn't wake the device on. However, when I turn it back again, they are displayed. I need to make them turn the screen on. Can you help me with this problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload