-2

I have an android application in which i am downloading the apk from web server and store it in local storage after storing in externel storage. I open the apk file programmatically and then I install the apk programmatically. This is my code for installing the app programmatically.

    Intent intent = new Intent(Intent.ACTION_VIEW);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        Uri contentUri = FileProvider.getUriForFile(MainActivity.this, "com.ariaware.store.fileProvider", file_path); // Here filepath is location of apk file in local storage
        intent.setDataAndType(contentUri, "application/vnd.android.package-archive");

    } else {
        intent.setDataAndType(Uri.fromFile(file_path), "application/vnd.android.package-archive");
    }
    startActivityForResult(intent, INSTALL);

This code takes me to this Screen. Please have a look here. There are two options install and cancel on this screen. Now user needs to click on install in order to install the app. What I want user don't need to click on install. App should automatically install the app without asking from user. Any kind of help will be grateful I need your help guys i want to learn how can i install the apps in background

twana eng
  • 31
  • 10

1 Answers1

0

Of course, this is not possible. The possibility to bypass the users approval to install an app would be the biggest security flaw ever. Any malware, virus or malicious tool could just install itself without the user noticing.

muetzenflo
  • 5,653
  • 4
  • 41
  • 82
  • can u help me in this? https://stackoverflow.com/questions/5803999/install-apps-silently-with-granted-install-packages-permission – twana eng Apr 08 '20 at 19:12
  • Just read the answers in this post or the official documentation of this permission: https://developer.android.com/reference/android/Manifest.permission#INSTALL_PACKAGES -> Not given to third-party apps. You may get this permission on a rooted device, but this is another topic then. A normal app on a normal phone will never be able to install another app silently. This would be security suicide. – muetzenflo Apr 08 '20 at 21:13