6
6
import android .content .IntentSender ;
7
7
import android .util .Log ;
8
8
9
+ import com .google .android .gms .tasks .OnSuccessListener ;
10
+ import com .google .android .gms .tasks .Task ;
9
11
import com .google .android .play .core .appupdate .AppUpdateInfo ;
10
12
import com .google .android .play .core .appupdate .AppUpdateManager ;
11
13
import com .google .android .play .core .appupdate .AppUpdateManagerFactory ;
14
16
import com .google .android .play .core .install .model .AppUpdateType ;
15
17
import com .google .android .play .core .install .model .InstallStatus ;
16
18
import 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 ;
19
19
20
20
public class InAppUpdateUtils {
21
21
22
22
private static final int MY_REQUEST_CODE = 1056 ;
23
23
private AppUpdateManager appUpdateManager ;
24
24
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 ();
32
28
}
33
29
};
34
30
private int HIGH_PRIORITY_UPDATE = 5 ;
@@ -44,7 +40,6 @@ public void initAppUpdaterAndCheckForUpdate() {
44
40
Task <AppUpdateInfo > appUpdateInfoTask = appUpdateManager .getAppUpdateInfo ();
45
41
// and checks the update priority.
46
42
appUpdateInfoTask .addOnSuccessListener (appUpdateInfo -> {
47
- Log .e ("mye" , "appUpdateInfo " + appUpdateInfo .availableVersionCode () + "packageName " + appUpdateInfo .packageName () + "updateAvailability " + appUpdateInfo .updateAvailability () + "updatePriority " + appUpdateInfo .updatePriority ());
48
43
if (appUpdateInfo .updateAvailability () == UpdateAvailability .UPDATE_AVAILABLE
49
44
&& appUpdateInfo .updatePriority () >= HIGH_PRIORITY_UPDATE ) {
50
45
try {
0 commit comments