broadcastreceiver - Android: Detecting when device wake-up has occurred? -
i know v4 helper class called wakefulbroadcastreceiver, meant respond device wake-up.
i want write headless android app detects device has woken up, , performs whatever logic desire (in test app, below, logs message).
however, couldn't find out intent(s) specify in app's manifest, wakefulbroadcastreceiver fired off.
does know how configure such app, wakefulbroadcastreceiver detects instances of device wake-up?
first, here wakefulbroadcastreceiver:
public class mywakeupreceiver extends wakefulbroadcastreceiver { public void onreceive(context context, intent intent) { log.i("mywakeupreceiver", "received wake-up intent: " + intent.tostring()); startwakefulservice(context, new intent(context, mywakeupservice.class)); } } ... , here service gets run:
public class mywakeupservice extends intentservice { public mywakeupservice() { super("mywakeupservice"); } @override protected void onhandleintent(intent intent) { log.i("mywakeupservice", "onhandleintent: " + intent.tostring()); // stuff here. mywakeupreceiver.completewakefulintent(intent); } } finally, here manifest. note "what_goes_here????" in intent filter.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.test.package" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="19" android:targetsdkversion="19" /> <uses-permission android:name="android.permission.wake_lock" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <receiver android:name="my.test.package.mywakeupreceiver" android:enabled="true" android:exported="false"> <intent-filter> <action android:name="android.intent.action.what_goes_here????" /> </intent-filter> </receiver> <service android:name="my.test.package.mywakeupservice" /> </application> </manifest> thank much.
this question year old, did ever figure out? think actions wanted in intent filter bit android.intent.action.screen_on , android.intent.action.screen_off. i'm trying similar, have discovered mysterious reason actions can't registered in manifest.
Comments
Post a Comment