问题
I'm searching for a way to program my application to install silently an apk file. I'm aware about the possibility to launch code looks something like this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
startActivity(intent);
but this code raising before the installation starts a dialog with the apk's require permissions and needs the user to authorization to start the installation.
Is there any way to skip this dialog? Is there any other way to install application on run-time from my code that don't requires the user interaction?
回答1:
No. And that's a good thing, this would be an (other) open door to malware and unwanted installs. Why do you want to do that, if you mind me asking? What's wrong with letting users know that you want to install something on their device?
Also, some details here: Silent installation on Android devices
And finally, this might be possible for rooted devices: if you write your own installer, you can bypass completely the built-in installer, and with root privilege, you can basically do what you want. But I still think that would be a serious breach of security.
回答2:
Yes you can but you need root access or your app must be system signed app.
You can install app silent by using shell commmand pm install "apk path"
This will definatly work i have already created a sample app for same
来源:https://stackoverflow.com/questions/8077779/android-apks-silent-installation