My app needs to play a ringtone if an sms is coming in (broadcastreceiver). It's functioning correctly if my phone is on. But in sleep the SMS is coming in and nothing is happening. If I get the phone from standby...my ringtone is playing....
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
wl.acquire();
.. play the ringtone and do other actions..
wl.release();
in the manifest I putted also:
<uses-permission android:name="android.permission.WAKE_LOCK" />
Does anybody know what I'm missing?!
The phone is reacting at a Textmssage with a broadcast receiver. In de broadcast receiver I just start an activity
In that activity (new class) I put the OnCreate:
In the OnStop I put:
That worked for me.