Android get Google Play Store app version

前端 未结 8 1645
渐次进展
渐次进展 2021-02-06 11:49

I am using this code to get the Google Play Store app version but this is causing my app to hang. Please specify another way to get the app version or how I can use this code to

8条回答
  •  礼貌的吻别
    2021-02-06 12:13

    You can achieve this much easier using UpdateManager - https://developer.android.com/reference/com/google/android/things/update/UpdateManager

    You can setup your Update Manager as such

    // Creates instance of the manager.
    AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);
    
    // Returns an intent object that you use to check for an update.
    Task appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
    
    //On Success Listener
    appUpdateInfoTask.addOnSuccessListener(this);
    

    In your On Success method, you can call

    result.availableVersionCode()
    

    Which returns 0 when the version is not different. Which if it is different you can just pull this value from your app directly.

提交回复
热议问题