android.util.AndroidRuntimeException Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? com.uethinking.microvideo.manag

记录学习,网络摘抄

碰到这个异常其实这个上面说的很清楚,加个flag

从一个Activity中要通过intent调出另一个Activity的话,需要使用 FLAG_ACTIVITY_NEW_TASK

E/AndroidRuntime( ): FATAL EXCEPTION: main
E/AndroidRuntime( ): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS:

如果调出的Activtivity只是一个功能片段,并没有实际的意义,也没有必要出现在长按Home键调出最近使用过的程序类表中,那么使用FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

Intent intent = new Intent(this, WaitingFallBackDialog.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(intent);
上一篇:tar time stamp in the future 报错 解决方案


下一篇:GIt 从入门到放弃