有没有办法构建一个Android应用程序,可以静默地下载和安装其他apks,而不需要询问用户安装它们的许可?
到目前为止,下载apks很容易,问题在于安装它们时,因为它们需要用户批准才能安装。
到目前为止,我已经尝试了以下代码
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(s)), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // without this flag android returned a intent error!
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivityForResult(intent, INSTALL_APK);这需要用户批准才能安装apk。有没有其他方法可以在不提示用户的情况下完成此操作?
谢谢
发布于 2016-09-23 21:38:03
不可以,没有用户的许可,应用程序无法安装到安卓设备上,除非它是通过computer.The用户的隐私/权限政策进行开发的,因为谷歌实施的应用程序安装不允许任何应用程序或设备在没有用户权限的情况下安装新的应用程序。然而,频繁的应用程序升级可以在没有用户许可的情况下完成。
参考:https://support.google.com/a/users/answer/190930?hl=en
和
https://support.google.com/a/users/answer/2364439?hl=en
注意:有一些机制可以在没有用户权限的情况下安装apks,前提是设备是根设备。
发布于 2016-09-23 21:33:53
尝试其他开发人员(Palak)的回答,需要Root
public static void InstallAPK(String filename){
File file = new File(filename);
if(file.exists()){
try {
String command;
command = "adb install -r " + filename;
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}他可能也是从这个链接http://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/中取得的
https://stackoverflow.com/questions/39661964
复制相似问题