我需要将 apk 文件从服务器下载到设备,然后在没有任何用户交互的情况下静默安装。我正在使用有根的 android 设备。有可能吗?有什么办法可以做到吗?
我使用以下代码安装 apk。但它要求用户按安装或取消。
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(sdcard,"Android/data/com.mycompany.android.games/temp/temp.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag android returned a intent error!
context.startActivity(intent);