66import android .content .IntentSender ;
77import android .util .Log ;
88
9+ import com .google .android .gms .tasks .OnSuccessListener ;
10+ import com .google .android .gms .tasks .Task ;
911import com .google .android .play .core .appupdate .AppUpdateInfo ;
1012import com .google .android .play .core .appupdate .AppUpdateManager ;
1113import com .google .android .play .core .appupdate .AppUpdateManagerFactory ;
1416import com .google .android .play .core .install .model .AppUpdateType ;
1517import com .google .android .play .core .install .model .InstallStatus ;
1618import com .google .android .play .core .install .model .UpdateAvailability ;
17- import com .google .android .play .core .tasks .OnSuccessListener ;
18- import com .google .android .play .core .tasks .Task ;
1919
2020public class InAppUpdateUtils {
2121
2222 private static final int MY_REQUEST_CODE = 1056 ;
2323 private AppUpdateManager appUpdateManager ;
2424 private Activity activity ;
25- private InstallStateUpdatedListener listener = new InstallStateUpdatedListener () {
26- @ Override
27- public void onStateUpdate (InstallState state ) {
28- Log .e ("mye" , "state" + state .installStatus () + " -- " + state .installErrorCode ());
29- if (state .installStatus () == InstallStatus .DOWNLOADED ) {
30- showDialog ();
31- }
25+ private InstallStateUpdatedListener listener = state -> {
26+ if (state .installStatus () == InstallStatus .DOWNLOADED ) {
27+ showDialog ();
3228 }
3329 };
3430 private int HIGH_PRIORITY_UPDATE = 5 ;
@@ -44,7 +40,6 @@ public void initAppUpdaterAndCheckForUpdate() {
4440 Task <AppUpdateInfo > appUpdateInfoTask = appUpdateManager .getAppUpdateInfo ();
4541 // and checks the update priority.
4642 appUpdateInfoTask .addOnSuccessListener (appUpdateInfo -> {
47- Log .e ("mye" , "appUpdateInfo " + appUpdateInfo .availableVersionCode () + "packageName " + appUpdateInfo .packageName () + "updateAvailability " + appUpdateInfo .updateAvailability () + "updatePriority " + appUpdateInfo .updatePriority ());
4843 if (appUpdateInfo .updateAvailability () == UpdateAvailability .UPDATE_AVAILABLE
4944 && appUpdateInfo .updatePriority () >= HIGH_PRIORITY_UPDATE ) {
5045 try {
0 commit comments