From 837341943b2fbab457ed01de1ed59620a3ea84c1 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 2 Feb 2012 13:58:17 +0400 Subject: [PATCH] logging in LastLocation --- src/org/average/whereami/LastLocation.java | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/org/average/whereami/LastLocation.java b/src/org/average/whereami/LastLocation.java index 52b9098..bd25283 100644 --- a/src/org/average/whereami/LastLocation.java +++ b/src/org/average/whereami/LastLocation.java @@ -27,10 +27,16 @@ public final class LastLocation extends Oracle { 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, @@ -38,12 +44,15 @@ public final class LastLocation extends Oracle { 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); @@ -55,17 +64,22 @@ public final class LastLocation extends Oracle { @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(); -- 2.43.0