final String TAG = getClass().getName();
- private Latitude latitude;
-
private String[] loc_names;
private String[] loc_lats;
private String[] loc_lons;
myname = res.getString(R.string.myname);
registered = res.getString(R.string.registered);
sayWhen = new SayWhen(res);
-
- latitude = Latitude.builder(httpTransport, jsonFactory)
- .setHttpRequestInitializer(accessProtectedResource)
- .setApplicationName("WhereAmI/1.0").build();
}
@Override
public final String getResult() {
+ Latitude latitude = Latitude.builder(httpTransport, jsonFactory)
+ .setHttpRequestInitializer(accessProtectedResource())
+ .setApplicationName("WhereAmI/1.0").build();
try {
Log.v(TAG, "entering getResult");
Latitude.CurrentLocation.Get request =
public HttpTransport httpTransport;
public JsonFactory jsonFactory;
+ public PersistentStore store;
- public GoogleAccessProtectedResource accessProtectedResource;
public String authErrorMessage;
public Oracle(final Resources res, final PersistentStore store) {
authErrorMessage = res.getString(R.string.autherror);
+ this.store = store;
httpTransport = AndroidHttp.newCompatibleTransport();
jsonFactory = new JacksonFactory();
+}
+
+ public GoogleAccessProtectedResource accessProtectedResource() {
AccessTokenResponse token = store.readTokens();
Log.v(TAG, "tokens - access: \"" + token.accessToken +
"\", refresh: \"" + token.refreshToken +
"\", client_secret: \"" +
ClientCredentials.CLIENT_SECRET +
"\"");
- accessProtectedResource = new GoogleAccessProtectedResource(
+ return new GoogleAccessProtectedResource(
token.accessToken, httpTransport, jsonFactory,
ClientCredentials.CLIENT_ID,
ClientCredentials.CLIENT_SECRET,
calendar_name = store.get("calendar_name");
peer_name = store.get("peer_name");
calendar_id = store.get("calendar_id");
-
- calendar = Calendar.builder(httpTransport, jsonFactory)
- .setHttpRequestInitializer(accessProtectedResource)
- .setApplicationName("WhereAmI/1.0").build();
}
@Override
public final String getResult() {
+ calendar = Calendar.builder(httpTransport, jsonFactory)
+ .setHttpRequestInitializer(accessProtectedResource())
+ .setApplicationName("WhereAmI/1.0").build();
try {
Log.v(TAG, "entering getResult");
if (calendar_id == null || calendar_id == "") {
import android.app.Activity;
import android.net.wifi.WifiManager;
+import android.os.Build;
import android.os.Bundle;
import android.os.AsyncTask;
import android.os.Handler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO) {
+ Log.v(TAG, "Disabling keepalive for build version " +
+ Build.VERSION.SDK_INT);
+ System.setProperty("http.keepAlive", "false");
+ } else {
+ Log.v(TAG, "Post-Froyo version " +
+ Build.VERSION.SDK_INT);
+ }
prefs = PreferenceManager.getDefaultSharedPreferences(this);
store = new PersistentStore(prefs);
wifiman = (WifiManager)getSystemService(Context.WIFI_SERVICE);