diff --git a/app/build.gradle b/app/build.gradle
index 530d443f..ec39ab6d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
+apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 21
@@ -24,5 +25,5 @@ dependencies {
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:support-annotations:22.0.0'
- compile 'com.google.android.gms:play-services-gcm:7.0.0'
+ compile 'com.google.android.gms:play-services-gcm:7.5.0'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0ca2809c..d76c0187 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -33,6 +33,7 @@
android:name="android.permission.ACCESS_NETWORK_STATE" />
+
@@ -100,15 +101,35 @@
android:resource="@xml/syncadapter" />
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/example/android/sunshine/app/MainActivity.java b/app/src/main/java/com/example/android/sunshine/app/MainActivity.java
index 4960cfa2..0464c16f 100644
--- a/app/src/main/java/com/example/android/sunshine/app/MainActivity.java
+++ b/app/src/main/java/com/example/android/sunshine/app/MainActivity.java
@@ -25,7 +25,7 @@
import com.example.android.sunshine.app.sync.SunshineSyncAdapter;
import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.GooglePlayServicesUtil;
+import com.google.android.gms.common.GoogleApiAvailability;
public class MainActivity extends ActionBarActivity implements ForecastFragment.Callback {
@@ -67,11 +67,10 @@ protected void onCreate(Bundle savedInstanceState) {
SunshineSyncAdapter.initializeSyncAdapter(this);
if (!checkPlayServices()) {
- // this is where we could either prompt a user that they should install
+ // This is where we could either prompt a user that they should install
// the latest version of Google Play Services, or add an error snackbar
// that some features won't be available.
}
-
}
@Override
@@ -93,22 +92,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
startActivity(new Intent(this, SettingsActivity.class));
return true;
}
+
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
super.onResume();
-
- // If Google Play Services is not available, some features, such as GCM-powered weather
- // alerts, will not be available.
- if (!checkPlayServices()) {
- // Store regID as null
- }
-
- String location = Utility.getPreferredLocation(this);
+ String location = Utility.getPreferredLocation( this );
// update the location in our second pane using the fragment manager
- if (location != null && !location.equals(mLocation)) {
+ if (location != null && !location.equals(mLocation)) {
ForecastFragment ff = (ForecastFragment)getSupportFragmentManager().findFragmentById(R.id.fragment_forecast);
if ( null != ff ) {
ff.onLocationChanged();
@@ -149,10 +142,11 @@ public void onItemSelected(Uri contentUri) {
* the Google Play Store or enable it in the device's system settings.
*/
private boolean checkPlayServices() {
- int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
+ GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
+ int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
- if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
- GooglePlayServicesUtil.getErrorDialog(resultCode, this,
+ if (apiAvailability.isUserResolvableError(resultCode)) {
+ apiAvailability.getErrorDialog(this, resultCode,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(LOG_TAG, "This device is not supported.");
diff --git a/build.gradle b/build.gradle
index 6356aabd..cfad1887 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,6 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
+ classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files