Skip to content
Snippets Groups Projects
Commit 3699e02c authored by Peter Joseph De Jonckheere CESM2014's avatar Peter Joseph De Jonckheere CESM2014
Browse files

Attempt to fix occasional crashes

parent f550afb4
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ import com.google.android.gms.awareness.snapshot.LocationResponse; ...@@ -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.PlacesResponse;
import com.google.android.gms.awareness.snapshot.WeatherResponse; import com.google.android.gms.awareness.snapshot.WeatherResponse;
import com.google.android.gms.awareness.state.Weather; 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.common.api.GoogleApiClient;
import com.google.android.gms.location.places.Place; import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.PlaceLikelihood; import com.google.android.gms.location.places.PlaceLikelihood;
...@@ -193,7 +194,11 @@ public class SaveFile { ...@@ -193,7 +194,11 @@ public class SaveFile {
} }
} }
recordTimeStamp(sent, clicked, movement, acknowledged, context); recordTimeStamp(sent, clicked, movement, acknowledged, context);
getExtraData(context); try {
getExtraData(context);
}catch(ApiException e){
}
if(sent == 1 || acknowledged == 1){ if(sent == 1 || acknowledged == 1){
DataAnalysis.placeAnalysis(context); DataAnalysis.placeAnalysis(context);
} }
...@@ -306,7 +311,7 @@ public class SaveFile { ...@@ -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), SharedPreferences preferences = context.getSharedPreferences(context.getString(R.string.preference_file_key),
Context.MODE_PRIVATE); Context.MODE_PRIVATE);
double latitude = Double.longBitsToDouble(preferences.getLong(context.getString(R.string.store_lat), 0)); double latitude = Double.longBitsToDouble(preferences.getLong(context.getString(R.string.store_lat), 0));
...@@ -368,7 +373,7 @@ public class SaveFile { ...@@ -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; GoogleApiClient client;
client = new GoogleApiClient.Builder(context) client = new GoogleApiClient.Builder(context)
.addApi(Awareness.getSnapshotClient(context).getApi()).build(); .addApi(Awareness.getSnapshotClient(context).getApi()).build();
...@@ -386,8 +391,8 @@ public class SaveFile { ...@@ -386,8 +391,8 @@ public class SaveFile {
SharedPreferences preferences = context.getSharedPreferences(context.getString(R.string.preference_file_key), SharedPreferences preferences = context.getSharedPreferences(context.getString(R.string.preference_file_key),
Context.MODE_PRIVATE); Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); 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_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_long), Double.doubleToLongBits(task.getResult().getLocation().getLongitude()));
editor.commit(); editor.commit();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment