diff --git a/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java b/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java index bf23906f804f83d1861042f13a13fc348bd34ae3..6f845e467c6e4b11007a19ae3329c03d76e47aab 100644 --- a/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java +++ b/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java @@ -14,6 +14,7 @@ import com.google.android.gms.awareness.snapshot.LocationResponse; import com.google.android.gms.awareness.snapshot.PlacesResponse; import com.google.android.gms.awareness.snapshot.WeatherResponse; import com.google.android.gms.awareness.state.Weather; +import com.google.android.gms.common.api.ApiException; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.places.Place; import com.google.android.gms.location.places.PlaceLikelihood; @@ -193,7 +194,11 @@ public class SaveFile { } } recordTimeStamp(sent, clicked, movement, acknowledged, context); - getExtraData(context); + try { + getExtraData(context); + }catch(ApiException e){ + + } if(sent == 1 || acknowledged == 1){ DataAnalysis.placeAnalysis(context); } @@ -306,7 +311,7 @@ public class SaveFile { } - public static void recordData(Context context) { + public static void recordData(Context context) { SharedPreferences preferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), Context.MODE_PRIVATE); double latitude = Double.longBitsToDouble(preferences.getLong(context.getString(R.string.store_lat), 0)); @@ -368,7 +373,7 @@ public class SaveFile { } - private static void getExtraData(final Context context){ + private static void getExtraData(final Context context) throws ApiException{ GoogleApiClient client; client = new GoogleApiClient.Builder(context) .addApi(Awareness.getSnapshotClient(context).getApi()).build(); @@ -386,8 +391,8 @@ public class SaveFile { SharedPreferences preferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); - editor.putLong(context.getString(R.string.store_lat), Double.doubleToLongBits(task.getResult().getLocation().getLatitude())); - editor.putLong(context.getString(R.string.store_long), Double.doubleToLongBits(task.getResult().getLocation().getLongitude())); + editor.putLong(context.getString(R.string.store_lat), Double.doubleToLongBits(task.getResult().getLocation().getLatitude())); + editor.putLong(context.getString(R.string.store_long), Double.doubleToLongBits(task.getResult().getLocation().getLongitude())); editor.commit(); }