private Latitude latitude;
- public LastLocation(CredentialStore store) {
+ public LastLocation(final CredentialStore store) {
HttpTransport transport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
AccessTokenResponse token = store.read();
+ Log.v(TAG, "tokens - access: \"" + token.accessToken +
+ "\", refresh: \"" + token.refreshToken +
+ "\", client_id: \"" + ClientCredentials.CLIENT_ID +
+ "\", client_secret: \"" +
+ ClientCredentials.CLIENT_SECRET +
+ "\"");
GoogleAccessProtectedResource accessProtectedResource =
new GoogleAccessProtectedResource(
token.accessToken,
ClientCredentials.CLIENT_ID,
ClientCredentials.CLIENT_SECRET,
token.refreshToken)
- //{
- //@Override
- //public void onAccessToken(String accessToken) {
- // store.updateAccessToken(accessToken);
- // }
- //}
+ {
+ @Override
+ public void onAccessToken(
+ String accessToken) {
+ Log.v(TAG, "Update access token to \"" + accessToken + "\"");
+ store.updateAccessToken(
+ accessToken);
+ }
+ }
;
Latitude.Builder lbldr = Latitude.builder(transport,
jsonFactory);
@Override
public final String getResult() {
try {
+ Log.v(TAG, "entering getResult");
Latitude.CurrentLocation.Get request =
latitude.currentLocation().get();
request.setGranularity("best");
Location currentLocation = request.execute();
return locationMessage(currentLocation);
} catch (Exception ex) {
+ Log.v(TAG, "exception in getResult: " + ex);
+ ex.printStackTrace();
return ex.getMessage();
}
}
private String locationMessage(Location currentLocation) {
+ Log.v(TAG, "entering locationMessage: " +
+ currentLocation);
// lat = currentLocation.getLatitude();
// lon = currentLocation.getLongitude();
// tsm = currentLocation.getTimestampMs();