title: Android install apk programmatically error - Package Parse error
body: <p>I create an Edittext at my page, to allow user to update the apps by downloading the apk and install.  I am using loojp library to handle the Asynctask.</p>
  
  <p>My code at activity:</p>
  
  <pre><code>f0textupdate.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(final View view) {
              try {
                  view.setEnabled(false);
                  final ProgressBar f0progress = (ProgressBar) findViewById(R.id.f0progress);
                  f0progress.setProgress(0);
                  mHttpClient.get("http://google.com/apps.apk", new FileAsyncHttpResponseHandler(lastcreated) {
  
                      @Override
                      public void onSuccess(int i, Header[] headers, File file) {
                          //sendBroadcast(new Intent(Intent.ACTION_INSTALL_PACKAGE, Uri.fromFile(file)));
                          try {
                              String path = file.getParent()+"/"+ CfgMain.siteid+ ".apk";
                              File dst = new File(path);
                              if (!dst.exists()) {
                                  try {
                                      dst.createNewFile();
                                  } catch (IOException e) {
                                      e.printStackTrace();
                                  }
                              }
  
                              InputStream in = new FileInputStream(file);
                              OutputStream out = new FileOutputStream(dst);
  
                              // Transfer bytes from in to out
                              byte[] buf = new byte[1024];
                              int len;
                              while ((len = in.read(buf)) &gt; 0) {
                                  out.write(buf, 0, len);
                              }
                              in.close();
                              out.close();
  
                              Intent installIntent = new Intent();
                              installIntent.setAction(Intent.ACTION_INSTALL_PACKAGE);
                              installIntent.setDataAndType(Uri.fromFile(dst), "application/vnd.android.package-archive");
                              installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
                              installIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
                              installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                              startActivity(installIntent);
  
                          } catch (FileNotFoundException e) {
                              e.printStackTrace();
                          } catch (IOException e) {
                              e.printStackTrace();
                          }
                      }
  
                      @Override
                      public void onFailure(int i, Header[] headers, Throwable throwable, File file) {
                          if (file.exists()) {
                              file.delete();
                          }
                      }
  
                      @Override
                      public void onProgress(long bytesWritten, long totalSize) {
                          int totProgress = (int) (((float) bytesWritten * 100) / totalSize);
                          if (totProgress &gt; 0) {
                              f0progress.setVisibility(View.VISIBLE);
                              f0progress.setProgress(totProgress);
                          }
                      }
  
                  });
              } catch (Exception ex) {
  
              }
  
          }
      });
  </code></pre>
  
  <p>Manifest.xml</p>
  
  <pre><code>   &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.BLUETOOTH" /&gt;
  &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /&gt;
  &lt;uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /&gt;
  </code></pre>
  
  <p>It prompt an error message "Package parse error".</p>
  
  <p>1) do I need to convert the filename as per the original apk name after download, as the "File file" seem storing as a temporarily name without extension</p>
  
  <p><strong>Update 1</strong>
  Error from logCat:</p>
  
  <p>05-17 11:17:19.142    4562-4562/? W/zipro﹕ Unable to open zip '/data/data/com.M28/cache/77lori.apk': Permission denied</p>
  
  <p>05-17 11:17:19.152    4562-4562/? W/PackageParser﹕ Unable to read AndroidManifest.xml of /data/data/com.MMM/cache/MM.apk
      java.io.FileNotFoundException: AndroidManifest.xml</p>
  
  <p><strong>Update 1.1</strong>
  - change the Onsuccess()</p>
  
  <ul>
  <li>add in additional permission at Manifest.xml</li>
  </ul>