Skip to content

Commit

Permalink
fix android deprecation warning (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendler committed Mar 6, 2024
1 parent 1d6e3c5 commit b2daca6
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void isAvailable(final Result result) {
return;
}

final boolean playStoreAndPlayServicesAvailable = isPlayStoreAndPlayServicesAvailable();
final boolean playStoreAndPlayServicesAvailable = isPlayStoreInstalled() && isPlayServicesAvailable();
final boolean lollipopOrLater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;

Log.i(TAG, "isAvailable: playStoreAndPlayServicesAvailable: " + playStoreAndPlayServicesAvailable);
Expand Down Expand Up @@ -180,14 +180,23 @@ private void launchReviewFlow(final Result result, ReviewManager manager, Review
flow.addOnCompleteListener(task -> result.success(null));
}

private boolean isPlayStoreAndPlayServicesAvailable() {
@SuppressWarnings("deprecation")
private boolean isPlayStoreInstalled() {
try {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.getPackageManager().getPackageInfo("com.android.vending", PackageManager.PackageInfoFlags.of(0));
} else {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
}
} catch (PackageManager.NameNotFoundException e) {
Log.i(TAG, "Play Store not installed.");
return false;
}

return true;
}

private boolean isPlayServicesAvailable() {
GoogleApiAvailability availability = GoogleApiAvailability.getInstance();
if (availability.isGooglePlayServicesAvailable(context) != ConnectionResult.SUCCESS) {
Log.i(TAG, "Google Play Services not available");
Expand Down

0 comments on commit b2daca6

Please sign in to comment.