android控制系统回退按钮再按一次退出程序
2016-06-29 17:02
579 查看
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if ((System.currentTimeMillis() - mExitTime) > 2000) { UIHelper.makeToast(this, "再按一次退出程序"); mExitTime = System.currentTimeMillis(); } else { Intent home = new Intent(Intent.ACTION_MAIN); home.addCategory(Intent.CATEGORY_HOME); startActivity(home); overridePendingTransition(R.anim.fade_in, R.anim.fade_out_bottom); } return true; } return super.onKeyDown(keyCode, event);}fade_in.xml:<alpha xmlns:android="http://schemas.android.com/apk/res/android"android:duration="400"android:fromAlpha="0.0"android:interpolator="@android:anim/decelerate_interpolator"android:toAlpha="1.0" />
fade_out_bottom:
<translate xmlns:android="http://schemas.android.com/apk/res/android"android:duration="400"android:fromYDelta="0"android:interpolator="@android:anim/accelerate_interpolator"android:toYDelta="100%p"android:zAdjustment="top" />
相关文章推荐
- Android中的FlexboxLayout
- Activity的启动模式
- 通过js调用android原生方法
- Android开发环境搭建
- Android RecyclerView设置item间距
- Android取消EditText自动默认获取焦点行为
- Android 热补丁动态修复框架小结
- 安卓报错
- Android软键盘弹出,返回键Activity不结束
- Android跨进程通信之ContentProvider
- Android开发中RecyclerView组件使用的一些进阶技讲解
- Android 应用Crash Log在Logcat中消失的问题 threadid=1: thread exiting with uncaught exception
- Android 获取图片真实宽高
- Android Studio 查找logcat 高亮显示
- Android 设备连接电脑显示offline
- 如何让Android中 dialog显示在屏幕底部
- Android开发报错:AppCompat does not support the current theme features
- Android ListView 图片异步加载和图片内存缓存
- Android 四大组件Broadcast
- android SwipeRefreshLayout google官方下拉刷新控件