zoukankan      html  css  js  c++  java
  • Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK fla

    从一个Activity中要通过intent调出另一个Activity的话,需要使用 FLAG_ACTIVITY_NEW_TASK 
    否则的话,会有force close: 
    03-01 18:49:37.888 E/AndroidRuntime( 2706): FATAL EXCEPTION: main 
    03-01 18:49:37.888 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); 


  • 相关阅读:
    JavaScript对iframe的DOM操作
    如何处理JSON中的特殊字符
    JavaScript引擎是单线程的
    JSONP跨域的原理解析
    四道JavaScript面试题检测你的js基本功
    让IE6也支持position:fixed
    Keras Layer 的 call(x) 和 input_shape
    C++文件读写 fwrite 和 fread
    Windows Ubuntu 子系统修改默认登陆用户·
    Python新建文件夹(如果不存在)
  • 原文地址:https://www.cnblogs.com/liupengcheng/p/5069997.html
Copyright © 2011-2022 走看看