-3

1) Can I add apk file as expansion file in android. 2) I am trying to launch app directly from external storage but getting error.

code:-

Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File("storage/emulated/0/Android/obb/devui1.example.com.testing/main.98376.devui1.example.com.testing.obb/app-debug.apk")), "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag android returned a intent error!
    startActivity(intent);
Vamsi Abbineni
  • 479
  • 3
  • 7
  • 23
Aditya
  • 9
  • 1

1 Answers1

0

USe this code to extract or install apk programatically.

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Use this link: https://stackoverflow.com/a/4969421/1223291

It will be download apk from download manager and install automatically.

Community
  • 1
  • 1
dipali
  • 10,966
  • 5
  • 25
  • 51