Parse error “installing an apk using intent” on Jelly Bean android -


I am creating an Android application that is capable of including over-the-air updates in the Android application. That's why I am generating a WebSave to obtain the annotation code so that I will compare the version of the installed application, if it is less then I will trigger a update to install from the server, I am using

  string path = environment .getExternalStorage directory () + "/ download /"; File file = new file (PATH); File.mkdirs (); File outputfile = new file (file, "yourapp.apk"); Download file (file_upport, outputfile); InstallApk (); // Download File Function Private Static Zero Download File (String URL, File Output File) {URL U = New URL (URL)); URL Connection Connection = U.open Connection (); Int contentLength = conn.getContentLength (); DataInputStream stream = new DataInputStream (u.openstream ()); Byte [] buffer = new byte [contentLength]; Stream.readFully (buffer); Stream.close (); DataOutputStream fos = New DataOutputStream (New FileOutputStream (outputFile)); Fos.write (buffer); Fos.flush (); Fos.close (); } Hold (FileNotFoundException e) {Log.e ("FileNotFoundException", "E +"); Return; } Hold (IOException e) {Log.e ("IOException", "E +"); Return; }} // Installation APK File Function Private Zero installApk () {Intent Installer = New Intent (); Installer.setAction (android.content.Intent.ACTION_VIEW); Installer.putExtra (Intent.ACTION_PACKAGE_REPLACED, "org.wannatrak.android"); Installer.setDataAndType (Uri.fromFile (new file (Environment.getExternalStorageDirectory () + "/ download /" + "yourapp.apk"), "app / vnd.android.package-archive"); Installer.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); This.startActivity; } I'm generating an Android application that is capable of adding over-the-air updating in the Android application. That's because I'm generating a website switcher to get the version code so that I will compare the version of the installed app. If it is low then I will trigger an update to install from the server, I am using. String path = environment GettyStorySeries Directory () + "/ Download /"; File file = new file (PATH); File.mkdirs (); File outputfile = new file (file, "yourapp.apk"); Download file (file_upport, outputfile); InstallApk (); // DownloadFile Function Private Static Zero Download File (string url, file output file) {try {url u = new URL (url); URL Connection Connection = U.open Connection (); Int contentLength = conn.getContentLength (); DataInputStream stream = new DataInputStream (u.openstream ()); Byte [] buffer = new byte [contentLength]; Stream.readFully (buffer); Stream.close (); DataOutputStream fos = New DataOutputStream (New FileOutputStream (outputFile)); Fos.write (buffer); Fos.flush (); Fos.close (); } Hold (FileNotFoundException e) {Log.e ("FileNotFoundException", "E +"); Return; } Hold (IOException e) {Log.e ("IOException", "E +"); Return; }} // Installation APK File Function Private Zero installApk () {Intent Installer = New Intent (); Installer.setAction (android.content.Intent.ACTION_VIEW); Installer.putExtra (Intent.ACTION_PACKAGE_REPLACED, "org.wannatrak.android"); Installer.setDataAndType (Uri.fromFile (new file (Environment.getExternalStorageDirectory () + "/ download /" + "yourapp.apk"), "app / vnd.android.package-archive"); Installer.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); This.startActivity; }  

The above work is fine up to 4.0 versions. If I'm trying in Jelly Bean "There is a parse error in the package error" Please help me solve this problem

Thank you.

You need to allow your APK file to be read. Install APK File Function:

  File File = New File (EnvironmentalGetEnsteenStore Directory ("+" / "Download" "yourapp.apk") file.setReadable (True, False)) ; Installer.setDataAndType (Uri.fromFile (file), "app / vnd.android.package-archive");  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -