Note that there are some explanatory texts on larger screens.

plurals
  1. POBroadcastReceiver doesn't wake up the phone
    text
    copied!<p>I have an alarm application. I generally know the lifecycle of the receiver and how to use WakeLock.</p> <p>Today however I was contacted by an user that have sent me a really strange log and complained that his alarm hasn't started until he have had unlocked the phone by himself. I used to have problems with phones going back to sleep after receiver completed its work and before activity was started, but creating WakeLock in the receiver seemed to fix the problem. At least until today - from log it seems that onReceive method wasn't called at all until user has unlocked phone by himself.</p> <p>Facts:</p> <ul> <li>it is the first case I have heard of</li> <li>it has happened a few times to the user, but not every time</li> <li>log is prepared by adding text to SQLite database. It doesn't seem to delay application in any significant way</li> <li>infomation from onReceive was recorded over 100 seconds after expected alarm start time. It is the first method call in onReceive</li> <li>alarm was started just after user has unlocked the phone</li> <li>I use AlarmManager.RTC_WAKEUP flag</li> <li>user says he doesn't have any custom rom. I wait for answer if he has any custom/special lockscreen</li> <li>phone model is Sony Xperia U ST25A, Android 4.0.4</li> </ul> <p>Any ideas what could be causing this problem? Is it possible that BroadcastReceiver's "inside" WakeLock doesn't work somehow?</p> <p>EDIT:</p> <p>I would like to emphasize the issue here - BroadcastReceiver should keep phone awake during its whole onReceive method. However in my case, it is either that</p> <ul> <li>phone falls to sleep before onReceive methods end (even before finishing "logging call")</li> <li>phone is not awaken by receiver at all</li> </ul> <p>Also, I would like to point out the fact that user has stated clearly - alarm has started precisely when he has unlocked phone by himself. Couple of times.</p> <p>Some code:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { Logger.initialize(context, "AlarmReceiver"); ... } </code></pre> <p>Logger methods:</p> <pre><code>public synchronized static void initialize(Context context, String text) { try { if (mInstance == null) { // this is the block that is runned BugSenseHandler.initAndStartSession(context, BUGSENSE_ID); mInstance = new Logger(context); log("== Logger initialized == from " + (text != null ? text : "")); // it stores times as well. Said // that alarm was started over 100 // seconds after it should } else { log("logger initialized again from " + (text != null ? text : "")); } } catch (Exception e) { try { BugSenseHandler.sendException(e); mInstance = null; } catch (Exception e2) { } } } </code></pre>
 

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