Apk文件下载在Android中使用Java时出错

我遵循了这个教程并得到错误“PARSING ERROR是一个问题包括包装” 。 我已在Android设备Samsung Galaxy S3中查看结果。

package com.mrfs.android.surveyapp.activities; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.util.Log; public class ApkFileAsync extends Activity { UpdateApp updateAppInstance; @Override public void onCreate(Bundle savedBundleInstance) { super.onCreate(savedBundleInstance); updateAppInstance = new UpdateApp(); updateAppInstance.setContext(getApplicationContext()); updateAppInstance.execute("http://demo.ingresssolutions.com/proposalmanagement/services/user/getApkFile"); } private class UpdateApp extends AsyncTask{ private Context context; public void setContext(Context contextf){ context = contextf; } @Override protected Void doInBackground(String... arg0) { try { URL url = new URL(arg0[0]); HttpURLConnection c = (HttpURLConnection) url.openConnection(); c.setRequestMethod("POST"); c.setDoOutput(true); c.connect(); String PATH = "/mnt/sdcard/Download/"; File file = new File(PATH); file.mkdirs(); File outputFile = new File(file,"surveyapp.apk"); if(outputFile.exists()){ outputFile.delete(); } FileOutputStream fos = new FileOutputStream(outputFile); InputStream is = c.getInputStream(); byte[] buffer = new byte[1024]; int len1 = 0; while ((len1 = is.read(buffer)) != -1) { fos.write(buffer, 0, len1); } fos.close(); is.close(); /* Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File("/mnt/sdcard/Download/update.apk")), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);*/ // without this flag android returned a intent error! Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); context.startActivity(intent); } catch (Exception e) { Log.e("UpdateAPP", "Update error! " + e.getMessage()); } return null; }} } 

Complete Action using对话框后,我尝试按下PACKAGE INSTALLERVERIFY AND INSTALL在两种情况下都出现此错误相同的错误。 清单文件

把你的表现变成喜欢的

在此处输入图像描述

这应该工作正常,我认为..如果没有工作,请发布你的教程链接我错过了..我需要检查它…我会更新答案…还提到你是如何通过日食或一些安装应用程序其他进程如导入apk …如果将apk导入到真实设备意味着请检查你的设备版本,如果它的s3勒芒它有ICS api级别包括14或15所以改变那..如果它的jellly bean意味着你可以使用多达18