Force update for the latest version of android app

12,298

Solution 1

I have to do the same thing but what i did i gonna share you i hope this will help you.

1> I get the previous code version of my application and store it the string.xml. like my live app version code is 1. And my new app version code is 1.1.

This code is tell us our app version code.

        PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);  
        int versionNumber = pinfo.versionCode;  
        String versionName = pinfo.versionName;  

2> Than check

if (newcodeversion > previouscodeversion) {

// open any activity or pop up }

3> And in the new activity place Text view with text "you have update version" and a button.And on the click of that button navigate to google play store.

                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse("Your application URL"));
                startActivity(i);  

Solution 2

It is not possible if the logic of comparing the versionCode and blocking the user isn't already placed inside the current app on PlayStore.

Solution 3

This is not difficult to do. Simply bar the user from having the core functionality of what ever your app is responsible for.

Example, if it is a calling app, do a version check, and if the user has not updated as yet, restrict the use of call making entirely.

According to @pieter-b, taken from Forcing Updates:

For this to work, some kind of logic the app uses needs to be under your control. And then without that part of logic the app won't work and you can show a message: "your app is out of date, please download the new version to continue use."

Consider a messenger app where traffic goes through your servers. Just refuse to deliver messages of clients using an outdated version.

Also refer to Force update android app when new version available.

Share:
12,298
Mamta Kaundal
Author by

Mamta Kaundal

Updated on June 05, 2022

Comments

  • Mamta Kaundal
    Mamta Kaundal about 2 years

    I am trying to figure out how to forcefully update the latest version from play store.

    As the older version of my android app is already in play store where i haven't implement the check to get the current version of the app and compare with the play store app version like specified in the link update android app forcefully

    I want that when I upload my new version on play store then user should not be able to use the app till he update the new version.

    Could you please help me out.

    • Sattar Hummatli
      Sattar Hummatli almost 8 years
      This open source GitHub project (MAHAndroidUpdater)is completely providing update functionality. Try it, Very simple. github.com/hummatli/MAHAndroidUpdater
  • Mamta Kaundal
    Mamta Kaundal about 8 years
    The older version which is on play store does not have this code. Now i am launching new version so i want user to update app forcefully.
  • Admin
    Admin about 8 years
    Is your application using webservices??
  • Mamta Kaundal
    Mamta Kaundal about 8 years
    Yes, app is using webservices.
  • Admin
    Admin about 8 years
    okay, and your app has admin panel too.So create one webservice which has your new version like 1.1.In my backend they have my app oldversion code. "webservicename?version=" + "1.1" And on the response of that webservice i am check checking the same. Like : if (mJsonObject.getString("update").equalsIgnoreCase("1")) { // update = mJsonObject.getString("update"); mendatory = mJsonObject.getString("mendatory"); item = mJsonObject.getString("item"); if (mendatory.equalsIgnoreCase("0")) { INtent of new activity }