I am creating an app, and I would like to show a notification to the user after booting or rebooting, to inform the user that the app is available if interested.
From what I understood, the following code should work
public class BootReceiver extends BroadcastReceiver {
private static final String TAG = "BootReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "BootReceiver triggered");
}
}
The log unfortunately does not show up. If I understand correctly, everytime an action is performed (like: ACTION_BOOT_COMPLETED or ACTION_USER_PRESENT), the onReceive() method should be triggered right? Or am I wrong?
For example, I know that these actions are restricted in recent androids, but I understood somehow that still onReceive() should work, and what may not work is the following code:
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) {}
Also, I understood that these actions are restricted for background activities, so: is pushing a notification permitted? If yes, how?