How to find if the phone is in standby / standby mode for Android?
My problem is that I can wake the phone from sleep mode using the alarm manager
But when the phone is not in sleep mode and at the same moment, if the alarm manager is used to swell the phone. Android power shuts down the app.
is there any way to find if the phone is in standby or standby? (black screen)
Update:
My requirement:
When the phone is in sleep mode ---> Intent should be started from the service When the phone is not in sleep mode → The same intention should be started from the service
None of the solutions below work fine, so here is my little tweak that worked fine :) :)
//Pending intent for my alarm manager Intent intentaa=new Intent(this,MyBroadcastReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intentaa, 0); //Intent to be launched where MyIntent is the intent Intent intenta = new Intent(); intenta.setClass(this, MyIntent.class); intenta.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //Real code try { startActivity(intenta); }catch(Exception E) { AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime(), pendingIntent); startActivity(intenta); }
source share