android 退出程序
2012-04-25 15:21
309 查看
1:
android.os.Process.killProcess(android.os.Process.myPid());
finish();
System.exit(0);
2:
Intent intent=new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
System.exit(0);
PS:使用第二种方式退出 会出现本来下载到sdcard的html文件自动删除,没有搞清楚原因,
知道的同学麻烦告诉我一下。
下载html的方法:
View Code
/article/2985382.html
android.os.Process.killProcess(android.os.Process.myPid());
finish();
System.exit(0);
2:
Intent intent=new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
System.exit(0);
PS:使用第二种方式退出 会出现本来下载到sdcard的html文件自动删除,没有搞清楚原因,
知道的同学麻烦告诉我一下。
下载html的方法:
View Code
public static Boolean writeStringToFile(String strInput, String pFilePaht) { OutputStream out = null; File file = new File(getRootPath() + pFilePaht); try { file.deleteOnExit(); file = createFile(pFilePaht); out = new FileOutputStream(file); byte[] bytes = strInput.getBytes(); out.write(bytes); out.flush(); return true; } catch (FileNotFoundException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } finally { file = null; try { if (out != null) out.close(); } catch (IOException e) { e.printStackTrace(); } } }
/article/2985382.html
相关文章推荐
- android 按返回键退出程序
- Android开发模板------再按一次退出程序 KeyEvent.KEYCODE_BACK
- Android 按2次back键程序才退出
- android中双击退出程序的帮助类
- Android双击返回键退出程序的实现方法
- Android退出程序
- Android程序退出后音乐不停止
- 如何让程序在按了 Android 的 Back 键后不关闭当前 From 或者不 APP 退出
- Android_Back键再按一次退出程序
- Android开发中退出程序的方法
- Android应用完全退出程序的方法!!!
- android 退出整个程序
- android退出整个程序的方法
- Android 重写系统Crash处理类,保存Crash信息到SD卡 和 完美退出程序的方法
- Android中的“再按一次返回键退出程序”实现
- Android连续点击两次Back键退出程序
- Android应用开发多个activity完全退出程序方法
- qml在stackView的情况下处理Android back键(返回键)全局双击back键退出程序
- Android程序中有多个Activity时的可全部退出方法
- Android程序真退出与假退出后台运行详解