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( 2706): FATAL EXCEPTION: main 
E/AndroidRuntime( 2706): 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); 

 

posted @ 2017-08-09 15:24  一只呆萌的萌呆  阅读(595)  评论(0编辑  收藏  举报