I know about the v4 helper class called WakefulBroadcastReceiver, which is meant to respond to a device wake-up.
I want to write a headless Android app which simply detects that the device has woken up, and then performs whatever logic I desire (in the test app, below, it simply logs a message).
However, I couldn't find out what Intent(s) to specify in the app's manifest, so that my WakefulBroadcastReceiver will get fired off.
Does anyone know how to configure such an app, so that a WakefulBroadcastReceiver detects all instances of device wake-up?
First, here is the 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));
}
}
... and here is the service that gets run:
public class MyWakeupService extends IntentService {
public MyWakeupService() {
super("MyWakeupService");
}
@Override
protected void onHandleIntent(Intent intent) {
Log.i("MyWakeupService", "onHandleIntent: " + intent.toString());
// Do stuff here.
MyWakeupReceiver.completeWakefulIntent(intent);
}
}
Finally, here is my manifest. Note "WHAT_GOES_HERE????" in the 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 you very much.