public class AlarmReceiver extends BroadcastReceiver { Intent intent1; // тэг для логов public final String TAG = getClass().getSimpleName(); @Override public void onReceive(Context context, Intent intent) { intent1 = new Intent(context, WakeUp.class); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent1); Log.e(TAG, "в Receiver"); } 

}

It gives an error: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

  • one
    try getAppliactionContext (). startActivity (intent1); - Kirill Stoianov
  • @KirillStoianov, thanks, it worked. - Ivan

1 answer 1

Use getAppliactionContext() to access the application context.