From: Eugene Crosser Date: Thu, 2 Feb 2012 09:58:17 +0000 (+0400) Subject: logging in LastLocation X-Git-Url: http://www.average.org/gitweb/?p=WhereAmI.git;a=commitdiff_plain;h=837341943b2fbab457ed01de1ed59620a3ea84c1;hp=4075fd74c86729ed0d774380f2c491a8e2a95c32;ds=sidebyside logging in LastLocation --- 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();