tha new dialog frament class is not being called y is this so ..?? it toasts the message as well as the toast in the exception
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();
}
}
}
您无法通过意图开始片段-您需要开始活动
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.