本文整理汇总了Java中com.google.api.client.googleapis.services.GoogleClientRequestInitializer类的典型用法代码示例。如果您正苦于以下问题:Java GoogleClientRequestInitializer类的具体用法?Java GoogleClientRequestInitializer怎么用?Java GoogleClientRequestInitializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GoogleClientRequestInitializer类属于com.google.api.client.googleapis.services包,在下文中一共展示了GoogleClientRequestInitializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGAEService
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
private void initGAEService() {
if (service != null) {
return;
}
if (mGoogleSignInAccount == null) {
return;
}
GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(mContext,
"server:client_id:" + Constants.SERVER_CLIENT_ID);
credential.setSelectedAccountName(mGoogleSignInAccount.getEmail());
Log.d(TAG, "credential account name" + credential.getSelectedAccountName());
U2fRequestHandler.Builder builder = new U2fRequestHandler.Builder(
AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), credential)
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(
AbstractGoogleClientRequest<?> abstractGoogleClientRequest)
throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
service = builder.build();
}
示例2: trainingsApi
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
public TrainingApi trainingsApi() {
if (appEngineApi == null) {
TrainingApi.Builder builder = new TrainingApi.Builder(AndroidHttp.newCompatibleTransport(),
JacksonFactory.getDefaultInstance(), null)
.setApplicationName(BuildConfig.APPLICATION_ID)
.setRootUrl(APP_ENGINE_BASE_URL)
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
appEngineApi = builder.build();
}
return appEngineApi;
}
示例3: doInBackground
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
@Override
protected String doInBackground(String... params) {
if (myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
.setRootUrl("https://YOUR-PROJECT-ID.appspot.com/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
myApiService = builder.build();
}
try {
return myApiService.sayHi(params[0]).execute().getData();
} catch (IOException e) {
return e.getMessage();
}
}
示例4: doInBackground
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
@Override
protected String doInBackground(String... params) {
if (myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
.setRootUrl("http://YOUR-PROJECT-ID.appspot.com/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
myApiService = builder.build();
}
try {
return myApiService.sayHi(params[0]).execute().getData();
} catch (IOException e) {
return e.getMessage();
}
}
示例5: doInBackground
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
@Override
protected String doInBackground(Context... params) {
if (jokeApiService == null) {
final JokeApi.Builder builder = new JokeApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
jokeApiService = builder.build();
}
context = params[0];
try {
return jokeApiService.tellAJoke().execute().getData();
} catch (IOException e) {
return e.getMessage();
}
}
示例6: getEndpoints
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* *
*
* @return ShoppingAssistant endpoints to the GAE backend.
*/
static ShoppingAssistant getEndpoints() {
// Create API handler
ShoppingAssistant.Builder builder = new ShoppingAssistant.Builder(
AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), getRequestInitializer())
.setRootUrl(Constants.ROOT_URL)
.setGoogleClientRequestInitializer(
new GoogleClientRequestInitializer() {
@Override
public void initialize(
final AbstractGoogleClientRequest<?>
abstractGoogleClientRequest)
throws IOException {
abstractGoogleClientRequest
.setDisableGZipContent(true);
}
}
);
return builder.build();
}
开发者ID:googlearchive,项目名称:MobileShoppingAssistant-sample,代码行数:28,代码来源:CloudEndpointBuilderHelper.java
示例7: setupRegistration
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* Setting up the registration object for communicating with the backend server
*/
private void setupRegistration() {
if (mRegService == null) {
Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null);
//Run in the emulator, connect to local server
if (Utils.runningOnEmulator()) {
// Need setRootUrl and setGoogleClientRequestInitializer only for local testing,
// otherwise they can be skipped
builder
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest)
throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// Run on device, connect on real server
} else {
builder.setRootUrl("https://play-together-2015.appspot.com/_ah/api/");
}
mRegService = builder.build();
}
}
示例8: setupGame
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* Setting up the registration object for communicating with the backend server
*/
private void setupGame() {
if (mGameService == null) {
Game.Builder builder = new Game.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null);
//Run in the emulator, connect to local server
if (Utils.runningOnEmulator()) {
// Need setRootUrl and setGoogleClientRequestInitializer only for local testing,
// otherwise they can be skipped
builder
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest)
throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// Run on device, connect on real server
} else {
builder.setRootUrl("https://play-together-2015.appspot.com/_ah/api/");
}
mGameService = builder.build();
}
}
示例9: setUpEndpoint
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* Instantiates {@link FunnyApi} object
*/
private void setUpEndpoint() {
if(funnyEndpoint == null) { // Only do this once
FunnyApi.Builder builder = new FunnyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
.setApplicationName(getResources().getString(R.string.app_name))
// options for running against local devappserver
// - 10.0.2.2 is localhost's IP address in Android emulator
// - turn off compression when running against local devappserver
.setRootUrl("https://nanodegree-funny-endpoint-1024.appspot.com/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
funnyEndpoint = builder.build();
}
}
示例10: EndpointsTaskBagImpl
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
public EndpointsTaskBagImpl(TodoPreferences preferences,
LocalTaskRepository localRepository) {
super(preferences, localRepository, null);
// Production testing
//TaskApi.Builder builder = new TaskApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null);
// Local testing
TaskApi.Builder builder = new TaskApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
taskApiService = builder.build();
}
示例11: updateBuilder
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* Updates the Google client builder to connect the appropriate server based
* on whether LOCAL_ANDROID_RUN is true or false.
*
* @param builder Google client builder
* @return same Google client builder
*/
public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) {
if (LOCAL_ANDROID_RUN) {
builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/");
}
// only enable GZip when connecting to remote server
final boolean enableGZip = builder.getRootUrl().startsWith("https:");
builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
if (!enableGZip) {
request.setDisableGZipContent(true);
}
}
});
return builder;
}
示例12: doInBackground
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* The main method that creates an API call to our endpoint
* @param params
* @return
*/
@Override
protected DealBean doInBackground(Void... params) {
DealBean dealBean = new DealBean();
try {
MyApi api = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null).setRootUrl("https://skilled-outlook-686.appspot.com/_ah/api")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
request.setDisableGZipContent(true);
}
}).build();
dealBean = api.getDeals().execute();
} catch (Exception e) {
e.printStackTrace();
}
return dealBean;
}
示例13: prepareBuilder
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
private <T extends AbstractGoogleJsonClient.Builder> T prepareBuilder(T builder,
final HttpRequestInitializer delegate,
GoogleClientRequestInitializer googleClientRequestInitializer) {
builder
.setHttpRequestInitializer(getHttpRequestInitializer(delegate))
.setApplicationName(applicationName)
.setGoogleClientRequestInitializer(googleClientRequestInitializer);
if (rootUrl.isPresent()) {
builder.setRootUrl(rootUrl.get());
}
if (servicePath.isPresent()) {
builder.setServicePath(servicePath.get());
}
return builder;
}
示例14: updateBuilder
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* Updates the Google client builder to connect the appropriate server based
* on whether LOCAL_ANDROID_RUN is true or false.
*
* @param builder
* Google client builder
* @return same Google client builder
*/
public static <B extends AbstractGoogleClient.Builder> B updateBuilder(
B builder) {
if (LOCAL_ANDROID_RUN) {
builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID
+ "/_ah/api/");
}
// only enable GZip when connecting to remote server
final boolean enableGZip = builder.getRootUrl().startsWith("https:");
builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
public void initialize(AbstractGoogleClientRequest<?> request)
throws IOException {
if (!enableGZip) {
request.setDisableGZipContent(true);
}
}
});
return builder;
}
示例15: updateBuilder
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer; //导入依赖的package包/类
/**
* Updates the Google client builder to connect the appropriate server based on whether
* LOCAL_ANDROID_RUN is true or false.
*
* @param builder Google client builder
* @return same Google client builder
*/
public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) {
if (LOCAL_ANDROID_RUN) {
builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/");
}
// only enable GZip when connecting to remote server
final boolean enableGZip = builder.getRootUrl().startsWith("https:");
builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> request) {
if (!enableGZip) {
request.setDisableGZipContent(true);
}
}
});
return builder;
}
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-android-client,代码行数:27,代码来源:CloudEndpointBuilderHelper.java