Programatically trigger app update from google play

为君一笑 提交于 2019-12-02 06:37:24
  1. Usually update is installed within 24 hours, provided the user maintains active connection with internet and sufficient battery. Android boxes do not have any battery, so automatic updates via google play (without any user interaction) are not reliable.

  2. Use this code for issuing auto update without playstore.

Add this permission: <uses-permission android:name="android.permission.ACCESS_SUPERUSER" />

Use the following function:

public static void installAPK(String filename) {
    File file = new File(filename);
    if (file.exists()) {
            Runtime.getRuntime().exec("chmod 777 " + filename);
            String command;
            command = "pm install -r " + filename;
            Process proc = Runtime.getRuntime().exec(new String[]{"su", "-c", command});
            proc.waitFor();
        }
}

Note: This would work only if you are not requesting any extra permissions for the app since last install.

  1. It depends on Google's back end replicating your new update, usually within 8-24 hours.
  2. No, that would be a security vulnerability. Apps are not permitted to install or update themselves without user interaction.

I have been through this many times.

1> It usually took me for about 2 - 4hrs to get my app updated on google play.

2> I think you are talking about force update. What I did for this was that I made an api for checking the version of app. And according to it I redirected to update screen in google play . I hope it helps.

// Here min_supported_version is generated from api
    if (min_supported_version <= BuildConfig.VERSION_CODE) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=yourpackagename")));
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!