Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update app from google play programmatically in android

In my app I have a link. When clicking on the link, I want to send the user to Google Play and update the app automatically.

I tried this:

// package name from menifest: com.infibond.infi
public void installInfiApplication(View view){
    final String apkurl = "market://details?id=" + "com.infibond.infi";
    final Uri marketUri = Uri.parse(apkurl);

    Intent promptInstall = new Intent(Intent.ACTION_VIEW).setData(marketUri);
    startActivity(promptInstall);
}

But this sent the user to the store without updating the app.

Is there a way to do it? If yes then what is it?

like image 269
OShiffer Avatar asked Oct 30 '22 06:10

OShiffer


1 Answers

Google does not currently provide a way to automatically start updating an app through an Intent. It seems unlikely that they ever will since it takes control of app installations away from users. Users can however enable auto updates for your app to get updates as soon as they are available unless the update requires new permissions (pre Android Marshmallow).

like image 59
RJ Aylward Avatar answered Nov 10 '22 07:11

RJ Aylward