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