zoukankan      html  css  js  c++  java
  • android 按返回键最小化(后台运行)

    在网上搜,发现有部分人提出的是如下代码:

     //   Intent intent = new Intent();
    //   intent.setAction("android.intent.action.MAIN");
    //   intent.addCategory("android.intent.category.HOME");
    //   startActivity(intent);

          此代码实际是跳转到系统桌面。实际只需下述关键一行代码

     public boolean onKeyDown(int keyCode, KeyEvent event) {
      if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
       moveTaskToBack(true);
       return true;
      }
      return super.onKeyDown(keyCode, event);
     }

    Move the task containing this activity to the back of the activity stack. The activity's order within the task is unchanged.

    • Parameters:

    • nonRoot If false then this only works if the activity is the root of a task; if true it will work for any activity in a task.

    • Returns:

    • If the task was moved (or it was already at the back) true is returned, else false.

    分析:nonRoot“非根”,如果参数为true 则“是 -非根”,也就是如果当前界面不是应用程序的根界面;如果是false,则

    “非-非根”,双重否定为肯定,“是根”,也就是如果当前界面是应用程序的根界面。上述示例代码中,当前界面并不是应用程序的根界面,所以传入的是true.  执行效果和微信的效果一样。

  • 相关阅读:
    WebGL着色器32位浮点数精度损失问题
    Web地图呈现原理
    虚拟DOM详解
    webgl开发第一道坎——矩阵与坐标变换
    作为前端应当了解的Web缓存知识
    浅谈模板引擎
    WebGL中深度碰撞方法总结
    不加班的项目从排期开始
    从0到1带人做项目
    webgl自学笔记——深度监测与混合
  • 原文地址:https://www.cnblogs.com/chenlong-50954265/p/5476648.html
Copyright © 2011-2022 走看看