The code in Android runs a simple method specifying Apk

  • 2020-05-24 06:10:06
  • OfStack

Sometimes, when we write our own applications, we need to code the specified apk, install the specified theme, or install the new apk. This can be done by:


private void installAPK(String apkUrl) {  
  Intent intent = new Intent(Intent.ACTION_VIEW);  
  intent.setDataAndType(Uri.parse("file://" + apkUrl),  
    "application/vnd.android.package-archive");  
  startActivity(intent);//  The installation   
 }  

apkUrl refers to the path of the application, and Intent is used to open Apk for installation.


Related articles: