I have a BackgroundReceiver
set up to receive the android.intent.action.USER_PRESENT
in the manifest file as per:
<receiver android:name="com.demo.MyBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
My overridden onReceive(Context, Intent)
method is very simple:
@Override
public void onReceive(Context context, Intent intent)
{
if (intent != null)
{
if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())
{
// wrapper for Log.d(String, String)
Dbug.log("MyBroadcastReceiver: [" + intent.getAction() + "]");
// this calls a service
serviceExample(context, intent);
}
}
}
Questions:
There is a comment by ubuntudroid on this answer (android app with service only) that says you need to start your activity at least once before it will correctly receive the required intents.
Apparently introduced in Android 3.0.
I have not tested this theory yet, but it would explain what you are seeing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With