top of page

Update Android Application if new version available

Help of play core library provided by google.

  • Check for update availability.

  • Start an update

  • Get a callback for update status

  • Handle a flexible update

  • Install a flexible update

  • Handle an immediate update

First add Library firebase remote config

we create in-app default values that control the behavior and appearance of our app

This is Available for version 4.1 of android if you are using another version of android studio check the newer version of android studio.

implementation ''

config update code :

 textCiewCurrentVersion = findViewById(;
    textCiewCurrentVersion.setText(" Current Version Code: "  +getVersionCode());
    HashMap<String, Object> defaultsRate = new HashMap<>();
    defaultsRate.put("new_version_code", String.valueOf(getVersionCode()));
    mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
    FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()


    mFirebaseRemoteConfig.fetchAndActivate().addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
        public void onComplete(@NonNull Task<Boolean> task) {
            if (task.isSuccessful()) {
                final String new_version_code = mFirebaseRemoteConfig.getString("new_version_code");

                if(Integer.parseInt(new_version_code) > getVersionCode())
                    showTheDialog("com.facebook.lite", new_version_code );
            else Log.e("MYLOG", "mFirebaseRemoteConfig.fetchAndActivate() NOT Successful");


private PackageInfo pInfo;
public int getVersionCode() {
    pInfo = null;
    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        Log.i("MYLOG", "NameNotFoundException: "+e.getMessage());
    return pInfo.versionCode;

private void showTheDialog(final String appPackageName, String versionFromRemoteConfig){
    final AlertDialog dialog = new AlertDialog.Builder(this)
            .setTitle("Update Available")
            .setMessage("This version is Old, please update to version: "+versionFromRemoteConfig)
            .setPositiveButton("UPDATE", null)


    Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
    positiveButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("market://details?id=" + appPackageName)));
            catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("" + appPackageName)));

Now we need go and open app and go remote of firebase

In Add para meter add key Ex : new_version_code

From Config Update Code.

Hire an android developer to get quick help for all your android app development needs. with the hands-on android assignment help and android project help by Codersarts android expert. You can contact the android programming help expert any time; we will help you overcome all the issues and find the right solution.

Want to get help right now Or Want to know price quote CONTACT US NOW


bottom of page