Android按返回键,程序进入后台运行,不关闭程序,finishAcrivity
来源:互联网 发布:屏幕颜色校准软件 编辑:程序博客网 时间:2024/05/05 22:35
@Override
public
boolean
onKeyDown(
int
keyCode, KeyEvent event) {
if
(keyCode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(
false
);
return
true
;
}
return
super
.onKeyDown(keyCode, event);
}
主要是moveTaskToBack(false);方法,源码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* Move the task containing this activity to the back of the activity
* stack. The activity's order within the task is unchanged.
*
* @param 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.
*
* @return If the task was moved (or it was already at the
* back) true is returned, else false.
*/
public
boolean
moveTaskToBack(
boolean
nonRoot) {
try
{
return
ActivityManagerNative.getDefault().moveActivityTaskToBack(
mToken, nonRoot);
}
catch
(RemoteException e) {
// Empty
}
return
false
;
}
http://my.oschina.net/u/936286/blog/280098
0 0
- Android按返回键,程序进入后台运行,不关闭程序,finishAcrivity
- Android按返回键,程序进入后台运行,不关闭程序,finishAcrivity
- Android按下返回键后,程序不退出,进入后台运行。使用moveTaskToBack(boolean nonRoot)
- Android按返回键退出程序但不销毁,程序后台运行,同QQ退出处理方式
- Android按返回键退出程序但不销毁,程序后台运行,同QQ退出处理方式
- Android按返回键退出程序但不销毁,程序后台运行,同QQ退出处理方式
- Android按返回键退出程序但不销毁,程序后台运行,同QQ退出处理方式
- Android按返回键退出程序但不销毁,程序后台运行,同QQ退出处理方式
- Android按返回键退出程序但不销毁,程序后台运行,同QQ退出处理方式
- android监测程序进入后台以及从后台返回
- Android原理 不需要关闭后台运行程序
- Android原理 不需要关闭后台运行程序
- Android原理 不需要关闭后台运行程序
- Android原理 不需要关闭后台运行程序
- 程序进入后台运行NSTimer
- 捕捉 程序关闭或者 进入后台事件
- Android监听程序进入后台
- 返回键使程序后台,使用notification进入前台
- Android动画精讲一:从setTranslationX谈属性动画和view动画的区别
- [D3.js] SVG-Axes(坐标轴)
- mysql给函数,存储过程权限的问题
- 栈与队列相互实现
- Python 中 import和import...from的区别
- Android按返回键,程序进入后台运行,不关闭程序,finishAcrivity
- 读哲学书笔记
- linux(unix)下java应用占用cpu过高查找方法
- JVM学习笔记-垃圾回收器
- UIscrollView的属性及其协议方法
- 提供给开发者 10 款最好的 Python IDE
- 关于在android项目中使用fragment的个人经验
- 9大代理服务器软件的比较与分析
- System.gc(); 与Runtime.gc()的区别