android------为退出app提供系统退出确认对话框
来源:互联网 发布:mac word 用户权限 编辑:程序博客网 时间:2024/05/22 02:02
当按下系统键直接退出时,给个提示框,提示用户是否需要退出本次登录?
解析: 重写onKeyDown()方法。直接上代码
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { conLogout(); } return true;}public void conLogout() { final Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.confirmlogout); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { UserManage userManage = UserManage.get(Context); String ip = userManage.getLastLoginIP(); LoginActivity(); //返回登录界面 } }).setNegativeButton(R.string.cancel, null).create().show();; }private void LoginActivity() { finish(); Intent intent = new Intent(this,LoginActivity.class); startActivity(intent); }
0 0
- android------为退出app提供系统退出确认对话框
- Android实现“退出确认”对话框
- android 返回 弹出对话框 确认退出
- C#退出时弹对话框确认退出
- qml 程序退出确认对话框
- Android 监听返回键,弹出确认退出对话框
- Android 实现返回键退出弹出确认对话框
- android 返回键退出程序时弹出对话框请求确认退出
- Android退出程序二次确认
- Android : 二次确认退出应用程序
- QT5入门之5 - 确认退出对话框
- AlertDialog----确认单击物理键退出对话框
- Androidt退出登录时弹出确认对话框
- AlertDialog----确认单击物理键退出对话框
- android的退出对话框
- 双击,弹出对话框退出App
- android退出应用:弹出对话框退出应用
- android 退出APP
- 2016.8.9
- C++string字符串1.1
- 图的深度遍历
- 开源集锦(九)GitHub开源控件( Button)
- hdoj1466计算直线的交点数(经典dp)
- android------为退出app提供系统退出确认对话框
- 12.Hibernate二级缓存
- 单Activity多Fragment模式快速构建一个App
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep
- 在Android studio中导入第三方jar
- Mutex使用样例
- OpenCV学习笔记(三)
- 告诉你ListView的Adapter应该写在Activity外面还是里面
- 数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历