List of usage examples for com.google.api.client.googleapis.extensions.android.gms.auth GoogleAccountCredential initialize
@Override public void initialize(HttpRequest request)
From source file:com.bufarini.reminders.ui.Reminders.java
License:Apache License
public static Tasks getGoogleTasksService(final Context context, String accountName) { final GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(context, ListManager.TASKS_SCOPES);// ww w. j a va2 s . c om credential.setSelectedAccountName(accountName); Tasks googleService = new Tasks.Builder(TRANSPORT, JSON_FACTORY, credential) .setApplicationName(DateUtils.getAppName(context)) .setHttpRequestInitializer(new HttpRequestInitializer() { @Override public void initialize(HttpRequest httpRequest) { credential.initialize(httpRequest); httpRequest.setConnectTimeout(3 * 1000); // 3 seconds connect timeout httpRequest.setReadTimeout(3 * 1000); // 3 seconds read timeout } }).build(); return googleService; }
From source file:com.dealbreaker.cloud.backend.core.CloudBackend.java
License:Apache License
private Mobilebackend getMBSEndpoint() { // check if credential has account name final GoogleAccountCredential gac = mCredential == null || mCredential.getSelectedAccountName() == null ? null/*w w w . j a va2s .co m*/ : mCredential; // create HttpRequestInitializer HttpRequestInitializer hri = new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setBackOffPolicy(new ExponentialBackOffPolicy()); if (gac != null) { gac.initialize(request); } } }; // build MBS builder // (specify gac or hri as the third parameter) return new Mobilebackend.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), hri) .setRootUrl(Consts.ENDPOINT_ROOT_URL).build(); }
From source file:com.ericrgon.CloudBackend.java
License:Apache License
private Mobilebackend getMBSEndpoint() { // check if credential has account name final GoogleAccountCredential gac = credential == null || credential.getSelectedAccountName() == null ? null : credential;/*w w w . j a v a 2 s . com*/ // create HttpRequestInitializer HttpRequestInitializer hri = new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setBackOffPolicy(new ExponentialBackOffPolicy()); if (gac != null) { gac.initialize(request); } } }; // build MBS builder // (specify gac or hri as the third parameter) return new Mobilebackend.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), hri) .setRootUrl(Consts.ENDPOINT_ROOT_URL).build(); }
From source file:com.google.cloud.backend.neednow.core.CloudBackend.java
License:Apache License
public Mobilebackend getMBSEndpoint() { //if (mCredential != null) // Log.i("persisting account:", mCredential.getSelectedAccountName()); // check if credential has account name final GoogleAccountCredential gac = mCredential == null || mCredential.getSelectedAccountName() == null ? null/*from w w w .j a v a2s .c om*/ : mCredential; // create HttpRequestInitializer HttpRequestInitializer hri = new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setBackOffPolicy(new ExponentialBackOffPolicy()); if (gac != null) { gac.initialize(request); } } }; // build MBS builder // (specify gac or hri as the third parameter) return new Mobilebackend.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), hri) .setRootUrl(Consts.ENDPOINT_ROOT_URL).build(); }