Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Do something like this </p> <p>// First you need to download apk file.</p> <pre><code> String extStorageDirectory = Environment.getExternalStorageDirectory().toString(); File folder = new File(extStorageDirectory, "APPS"); folder.mkdir(); File file = new File(folder, "AnyName."+"apk"); try { file.createNewFile(); } catch (IOException e1) { e1.printStackTrace(); } /** * APKURL is your apk file url(server url) */ DownloadFile("APKURL", file); </code></pre> <p>// the DownloadFile function is</p> <pre><code> public void DownloadFile(String fileURL, File directory) { try { FileOutputStream f = new FileOutputStream(directory); URL u = new URL(fileURL); HttpURLConnection c = (HttpURLConnection) u.openConnection(); c.setRequestMethod("GET"); //c.setDoOutput(true); c.connect(); InputStream in = c.getInputStream(); byte[] buffer = new byte[1024]; int len1 = 0; while ((len1 = in.read(buffer)) &gt; 0) { f.write(buffer, 0, len1); } f.close(); } catch (Exception e) { System.out.println("exception in DownloadFile: --------"+e.toString()); e.printStackTrace(); } </code></pre> <p>and after downloading the apk file write this code</p> <pre><code> Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/APPS/" + "AnyName.apk")), "application/vnd.android.package-archive"); startActivity(intent); </code></pre> <p>// and give permission in manifest </p> <pre><code> &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; </code></pre> <p>it might help you, i used this for same as your need.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload