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

status error code 7503 needs to be resolved from awareness api

parent ef9e4ddd
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
......@@ -20,6 +21,9 @@
<meta-data
android:name="com.google.android.awareness.API_KEY"
android:value="AIzaSyDqliqBcEQQAvMZR-RengdLUJaAYeRKbgs"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name="com.notificationFramework.sedentary.frontEnd.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -8,6 +8,7 @@ import android.support.annotation.NonNull;
import android.util.Log;
import com.google.android.gms.awareness.Awareness;
import com.google.android.gms.awareness.AwarenessStatusCodes;
import com.google.android.gms.awareness.snapshot.LocationResponse;
import com.google.android.gms.awareness.snapshot.PlacesResponse;
import com.google.android.gms.awareness.snapshot.WeatherResponse;
......@@ -15,6 +16,7 @@ import com.google.android.gms.awareness.state.Weather;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.places.PlaceLikelihood;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.RuntimeExecutionException;
import com.google.android.gms.tasks.Task;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
......@@ -302,11 +304,12 @@ public class SaveFile {
String places = "";
String line;
ArrayList<String> contents = new ArrayList<String>();
for (PlaceLikelihood p : placeLikelihoods) {
places = places + " " + String.valueOf(p.getPlace().getName()) + " "
+ String.valueOf(p.getLikelihood() + "\n");
if(placeLikelihoods != null) {
for (PlaceLikelihood p : placeLikelihoods) {
places = places + " " + String.valueOf(p.getPlace().getName()) + " "
+ String.valueOf(p.getLikelihood() + "\n");
}
}
String writeLine = String.valueOf(latitude) + " " + String.valueOf(longitude) + " " + places
+ String.valueOf(temperature);
if (isExternalStorageMounted()) {
......@@ -361,8 +364,12 @@ 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()));
try {
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()));
}catch(RuntimeExecutionException e){
Log.d("ERROR", e.getMessage());
}
editor.commit();
}
......
......@@ -159,9 +159,12 @@ public class SedentaryStimulus extends BroadcastReceiver implements Stimulus {
//Returns true if notification is to be sent
private boolean checkAcknowledged(SharedPreferences shared, Context context){
int period = shared.getInt(context.getString(R.string.daily_goal), context.getResources().getInteger(R.integer.daily_goal_minutes));
float ackThreshold = (24/period) * threshold;
float avgAck = shared.getFloat(context.getString(R.string.avg_ack), 4);
if(avgAck < ackThreshold){
float ackThreshold = (24/period);
ackThreshold = ackThreshold * threshold;
Log.d("AVGTHRESH", String.valueOf(ackThreshold));
float avgAck = shared.getFloat(context.getString(R.string.avg_ack), 0);
Log.d("AVGACK", String.valueOf(avgAck));
if(avgAck > ackThreshold){
Intent i = new Intent(context.getApplicationContext(),
com.notificationFramework.stimulus.FeedbackStimulus.class);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context.getApplicationContext());
......
......@@ -163,7 +163,6 @@ public class SigMotionDetect extends Service implements StimulusStrategy {
R.integer.alarm_rc, i, 0);
am.cancel(pi);
SaveFile.recordNotification(0, 0, 1, 0, this);
getExtraData();
setUpClock();
prevSeconds = seconds;
}
......@@ -268,31 +267,7 @@ public class SigMotionDetect extends Service implements StimulusStrategy {
lbm.sendBroadcast(i);
}
private void getExtraData(){
SharedPreferences preferences = this.getSharedPreferences(getString(
R.string.preference_file_key), Context.MODE_PRIVATE);
try {
double latitude = Awareness.getSnapshotClient(this).getLocation()
.getResult().getLocation().getLatitude();
double longitude = Awareness.getSnapshotClient(this).getLocation()
.getResult().getLocation().getLongitude();
List<PlaceLikelihood> placeLikelihoods = Awareness.getSnapshotClient(this)
.getPlaces().getResult().getPlaceLikelihoods();
Weather weather = Awareness.getSnapshotClient(this).getWeather().getResult()
.getWeather();
SharedPreferences.Editor editor = preferences.edit();
editor.putLong(this.getString(R.string.store_lat),Double.doubleToLongBits(latitude));
editor.putLong(this.getString(R.string.store_long),Double.doubleToLongBits(longitude));
editor.putString(this.getString(R.string.store_place), String.valueOf(placeLikelihoods.get(0).getPlace().getName()));
editor.putFloat(this.getString(R.string.store_placelike), placeLikelihoods.get(0).getLikelihood());
editor.putFloat(this.getString(R.string.store_temp),weather.getTemperature(Weather.CELSIUS));
editor.commit();
SaveFile.recordData(latitude, longitude, placeLikelihoods, weather, this);
}catch(SecurityException e){
Intent i = new Intent(this, RequestPermission.class);
startActivity(i);
}
}
/**
* The method which reponds to a bind request for this service.
......
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