AUTO-UPDATE Android app

别等时光非礼了梦想. 提交于 2019-12-11 13:04:53

问题


I need to have a mechanism where an app auto-updates itself without any user interaction. The app is an off the shelf app (off market). Updates should happen in background without any click. How can we achieve this?


回答1:


This is not possible, except perhaps on rooted devices or via your own custom ROM. Apps cannot install or update any apps (their own app or the apps of others) without user involvement.




回答2:


this is possible, and don't need to be rooted. You only need to have a signed apk, and execute it in background.

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(externalStorageDir, dir+ "APP.apk")),"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

The user will be prompted while installing, because we should inform the privileges of the app.




回答3:


Solved this issue. Final solution was it cannot be done phones which are not rooted. On rooted phone we can run adb script to do so. While on un rooted phone we can download the apk in background and launch the installer activity that will ask user to click once to approve installing the apk.



来源:https://stackoverflow.com/questions/30101991/auto-update-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!