您的位置:首页 > 移动开发 > Android开发

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

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: