Load token
This commit is contained in:
parent
0a47e53ffb
commit
43c11574a8
4 changed files with 36 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
|
token.json
|
||||||
|
|
1
app/src/main/assets/token.example.json
Normal file
1
app/src/main/assets/token.example.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"token":"abcdefghijklmnop"}
|
|
@ -15,6 +15,11 @@ import com.rubenvandeven.heartbeatstreamer.heartrate.Activity_AsyncScanHeartRate
|
||||||
import com.rubenvandeven.heartbeatstreamer.heartrate.Activity_SearchUiHeartRateSampler;
|
import com.rubenvandeven.heartbeatstreamer.heartrate.Activity_SearchUiHeartRateSampler;
|
||||||
import com.rubenvandeven.heartbeatstreamer.heartrate.HeartRateService;
|
import com.rubenvandeven.heartbeatstreamer.heartrate.HeartRateService;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -127,4 +132,33 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the token for use with the syncing.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getToken() {
|
||||||
|
String json = null;
|
||||||
|
String token = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
InputStream is = getAssets().open("token.json");
|
||||||
|
int size = is.available();
|
||||||
|
byte[] buffer = new byte[size];
|
||||||
|
is.read(buffer);
|
||||||
|
is.close();
|
||||||
|
json = new String(buffer, "UTF-8");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(json);
|
||||||
|
token = jsonObject.getString("token'");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class HeartRateService extends Service {
|
||||||
requestAccessToPcc();
|
requestAccessToPcc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start main thread, request location updates, start synchronization.
|
* Start main thread, request location updates, start synchronization.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue