2
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");

}

}

Выдаёт ошибку: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

2
  • 1
    попробуйте getAppliactionContext().startActivity(intent1); 4 авг 2016 в 12:30
  • @KirillStoianov, спасибо, сработало.
    – Ivan
    4 авг 2016 в 12:40

1 ответ 1

4

Используйте getAppliactionContext() для доступа к контексту приложения

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.