簡體   English   中英

廣播接收機未調用新活動

[英]new activity not being called from broadcast receiver

new不會調用新對話框frament類嗎,是這樣.. ?? 它除了敬酒之外還敬酒消息

public class AlarmReceiver extends BroadcastReceiver {

 @Override
 public void onReceive(Context context, Intent intent) {
   try {
     Bundle bundle = intent.getExtras();
     String message = bundle.getString("alarm_message");
     Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
     Intent newIntent = new Intent(context, FireMissilesDialogFragment.class);
    newIntent.putExtra("alarm_message", message);
     newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  //   Toast.makeText(context, "1"+message, Toast.LENGTH_SHORT).show();

     context.startActivity(newIntent);
   //  Toast.makeText(context, "2"+message, Toast.LENGTH_SHORT).show();

    } catch (Exception e) {
     Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
     e.printStackTrace();

    }
 }

}

您無法通過意圖開始片段-您需要開始活動

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM