Install APK android code

 String imagePath = Environment.getExternalStorageDirectory().toString() + "/myapk.apk";
        // setting downloaded into image view
       
        Log.w("path", imagePath);
       
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(imagePath)), "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag android returned a intent error!
        startActivity(intent);

Comments