Skip to content Skip to sidebar Skip to footer

Rtc_wakeup Is Not Working

Currently i am working on a Broadcast Receiver application, in which i am making an Alarm which should display a message after we enter the seconds. I used RTC_WAKEUP, which means

Solution 1:

RTC_WAKEUP will not switch on the screen, all it does is wakes up thee cpu so that your job is done. For the Screen to be turned on you need a FULL wakelock to be acquired.

PowerManagerpm= (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
 PowerManager.WakeLockwl= pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK
                                      | PowerManager.ON_AFTER_RELEASE,
                                      "wakeup");
 wl.acquire();
 // ... do work...//show toask
 wl.release();

Solution 2:

Do yo have the permission in your Manifest?

<uses-permissionandroid:name="android.permission.WAKE_LOCK" />

Solution 3:

Fix your manifest. Instead of

<receiverandroid:name="MyBroadcastReceiver" >

you need:

<receiverandroid:name=".MyBroadcastReceiver" >

Solution 4:

Checked the google DeskClock app: com.android.deskclock.alarms.AlarmStateManager (it's a BroadcastReceiver)

In its onReceive function used goAsync():

@OverridepublicvoidonReceive(final Context context, final Intent intent) {
    finalPendingResultresult= goAsync();
    final PowerManager.WakeLockwl= AlarmAlertWakeLock.createPartialWakeLock(context);
    wl.acquire();
    AsyncHandler.post(newRunnable() {
        @Overridepublicvoidrun() {
            handleIntent(context, intent);
            result.finish();
            wl.release();
        }
    });
}

You should take a shot with that.

Post a Comment for "Rtc_wakeup Is Not Working"