Call blocking is required for BroadcastReceiver when phone is sleeping?

Attempting to write a broadcast receiver that handles incoming SMS messages. Do I need to use blocking / partial trail lock for this app to work even though the device slept due to foreground inactivity?

0


source to share


1 answer


I am trying to extend WakefulBroadcastReceiver to make things easier, so yes. For example:



public class MyBroadcastReceiver extends WakefulBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        final ComponentName comp = new ComponentName(context.getPackageName(),
                MyIntentService.class.getName());
        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}

      

+1


source







All Articles