我需要通过程序下载.apk文件,然后启动其活动。 我使用的代码如下Android下载的.apk文件损坏
private String downloadFile(String sourceURL, String destinationPath)
{
try {
URL url = new URL(sourceURL);
URLConnection connection = url.openConnection();
connection.connect();
// download the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(destinationPath);
byte data[] = new byte[1024];
int count;
while ((count = input.read(data)) > 0) {
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
//此编辑:使文件RW,否则apk文件将不被安装 调用Runtime.getRuntime()EXEC( “搭配chmod 666” +的DestinationPath) ;
message = "OK";
}
catch (MalformedURLException e) {