在ReceiveMsgService(extends Service)中,添加addFlags()方法。 Intent it = new Intent(mContext, ShowSmsActivity.class); it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(it);
想要启动一个Activity时,遭遇闪退并报错误提示如下: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? 错误分析: Context中有一个startActivity方法,Activity继承自Context,重载了startActivity方法。如果使用Activity的startActivity...
intent.putExtras(bundle); mContext.startActivity(intent); 报错如下: 06-28 11:24:40.359: E/AndroidRuntime(7397): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Isthisreally what you want? 06-28 11:...
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? 从Activity的上下文外部调用 startActivity()方法,需要FLAG_ACTIVITY_NEW_TASK 标志 解决 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK ); 1. Intent intent = new Inte...
在你提到的这个特定情况下,异常提示“calling startActivity() from outside of an activity context requires the FLAG_ACTIVITY_NEW_TASK flag. is this really what you want?”表明从非Activity的上下文中调用startActivity()方法时,没有正确设置FLAG_ACTIVITY_NEW_TASK标志。 说明为什么从非Activity上下文调用start...
很多人使用startActivity时候,会碰到如下的异常: Caused by: android.util.AndroidRuntimeException: 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? 二、错误分析: Context中有一个startActivity方法,Activity继承自Context,重载了startActivity方法。如果使用Activity的startActivity方法,不会有任何限制,而如果使用Context的start...
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK,程序员大本营,技术文章内容聚合第一站。
简介:在非Activity中使用startActivity:Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag问题描述在APP 1中启动APP 2中的Activity。 在非Activity中使用startActivity:Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW...
Context中有一个startActivity方法,Activity继承自Context,重载了startActivity方法。如果使用 Activity的startActivity方法,不会有任何限制,而如果使用Context的startActivity方法的话,就需要开启一个新的task,遇到上面那个异常的,都是因为使用了Context的startActivity方法。解决办法是,加一个flag。intent.addFlags(Intent.FLAG...