@@ -80,6 +80,8 @@ private boolean isGooglePlayStoreInstalled() {
8080 }
8181
8282 private boolean checkPlayServices () {
83+ // GoogleApiAvailability is the replacement for GooglePlayServicesUtil added in 7.3.
84+
8385 int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable (appContext );
8486 if (resultCode != ConnectionResult .SUCCESS ) {
8587 if (GooglePlayServicesUtil .isUserRecoverableError (resultCode ) && isGooglePlayStoreInstalled ()) {
@@ -103,15 +105,18 @@ private boolean checkPlayServices() {
103105 }
104106
105107 private void ShowUpdateGPSDialog (final int resultCode ) {
106- (( Activity ) appContext ) .runOnUiThread (new Runnable () {
108+ OneSignal .runOnUiThread (new Runnable () {
107109 @ Override
108110 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 );
110115 builder .setMessage ("To receive push notifications please press 'Update' to enable 'Google Play services'." ).setPositiveButton ("Update" , new OnClickListener () {
111116 @ Override
112117 public void onClick (DialogInterface dialog , int which ) {
113118 try {
114- GooglePlayServicesUtil .getErrorPendingIntent (resultCode , appContext , 0 ).send ();
119+ GooglePlayServicesUtil .getErrorPendingIntent (resultCode , activity , 0 ).send ();
115120 } catch (CanceledException e ) {
116121 } catch (Throwable e ) {
117122 e .printStackTrace ();
@@ -121,7 +126,7 @@ public void onClick(DialogInterface dialog, int which) {
121126 }).setNegativeButton ("Skip" , new OnClickListener () {
122127 @ Override
123128 public void onClick (DialogInterface dialog , int which ) {
124- final SharedPreferences prefs = OneSignal .getGcmPreferences (appContext );
129+ final SharedPreferences prefs = OneSignal .getGcmPreferences (activity );
125130 SharedPreferences .Editor editor = prefs .edit ();
126131 editor .putBoolean ("GT_DO_NOT_SHOW_MISSING_GPS" , true );
127132 editor .commit ();
0 commit comments