0
public class RestartService extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            context.startForegroundService(new Intent(context,ApplicationStaterService.class));
        } else {
            context.startService(new Intent(context,ApplicationStaterService.class));
        }
        Log.i("Form BrsdCast","Run");

        boolean shouldStart = intent.getBooleanExtra("startAct",false);
        String url = intent.getStringExtra("urlData");
        assert url != null;
        Log.i("Form BrsdCast",url);
        if (shouldStart && !url.isEmpty()){
            Log.i("Form_BrsdCast",url);
            launchAct(url,context);
        }
    }

    private void launchAct(String url,Context context) {
        Intent intent = new Intent(context,Check.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        Toast.makeText(context, "TESTDDDDD", Toast.LENGTH_SHORT).show();
    }

}

This Will Run-in background every time whenever it receives it should start the activity from the background even the application is not running

Mahafuz Zaman
  • 95
  • 1
  • 1
  • 5

1 Answers1

0

You have to allow permission to Display over other applications

How to programmatically grant the "draw over other apps" permission in android?

Mahafuz Zaman
  • 95
  • 1
  • 1
  • 5