@@ -80,6 +80,8 @@ private boolean isGooglePlayStoreInstalled() {
80
80
}
81
81
82
82
private boolean checkPlayServices () {
83
+ // GoogleApiAvailability is the replacement for GooglePlayServicesUtil added in 7.3.
84
+
83
85
int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable (appContext );
84
86
if (resultCode != ConnectionResult .SUCCESS ) {
85
87
if (GooglePlayServicesUtil .isUserRecoverableError (resultCode ) && isGooglePlayStoreInstalled ()) {
@@ -103,15 +105,18 @@ private boolean checkPlayServices() {
103
105
}
104
106
105
107
private void ShowUpdateGPSDialog (final int resultCode ) {
106
- (( Activity ) appContext ) .runOnUiThread (new Runnable () {
108
+ OneSignal .runOnUiThread (new Runnable () {
107
109
@ Override
108
110
public void run () {
109
- AlertDialog .Builder builder = new AlertDialog .Builder (appContext );
111
+ final Activity activity = ActivityLifecycleHandler .curActivity ;
112
+ if (activity == null )
113
+ return ;
114
+ AlertDialog .Builder builder = new AlertDialog .Builder (activity );
110
115
builder .setMessage ("To receive push notifications please press 'Update' to enable 'Google Play services'." ).setPositiveButton ("Update" , new OnClickListener () {
111
116
@ Override
112
117
public void onClick (DialogInterface dialog , int which ) {
113
118
try {
114
- GooglePlayServicesUtil .getErrorPendingIntent (resultCode , appContext , 0 ).send ();
119
+ GooglePlayServicesUtil .getErrorPendingIntent (resultCode , activity , 0 ).send ();
115
120
} catch (CanceledException e ) {
116
121
} catch (Throwable e ) {
117
122
e .printStackTrace ();
@@ -121,7 +126,7 @@ public void onClick(DialogInterface dialog, int which) {
121
126
}).setNegativeButton ("Skip" , new OnClickListener () {
122
127
@ Override
123
128
public void onClick (DialogInterface dialog , int which ) {
124
- final SharedPreferences prefs = OneSignal .getGcmPreferences (appContext );
129
+ final SharedPreferences prefs = OneSignal .getGcmPreferences (activity );
125
130
SharedPreferences .Editor editor = prefs .edit ();
126
131
editor .putBoolean ("GT_DO_NOT_SHOW_MISSING_GPS" , true );
127
132
editor .commit ();
0 commit comments