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
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.