当前位置: 首页>>代码示例>>Java>>正文


Java AndroidHttp.newCompatibleTransport方法代码示例

本文整理汇总了Java中com.google.api.client.extensions.android.http.AndroidHttp.newCompatibleTransport方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidHttp.newCompatibleTransport方法的具体用法?Java AndroidHttp.newCompatibleTransport怎么用?Java AndroidHttp.newCompatibleTransport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.extensions.android.http.AndroidHttp的用法示例。


在下文中一共展示了AndroidHttp.newCompatibleTransport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupRegistration

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的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();
    }
}
 
开发者ID:rainbowbreeze,项目名称:playtogether,代码行数:29,代码来源:BackendHelper.java

示例2: setupGame

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的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();
    }
}
 
开发者ID:rainbowbreeze,项目名称:playtogether,代码行数:29,代码来源:BackendHelper.java

示例3: sync

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
private static void sync(Context context, boolean fullSync) {
  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
  GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(context,
      "server:client_id:988087637760-6rhh5v6lhgjobfarparsomd4gectmk1v.apps.googleusercontent.com");
  String accountName = preferences.getString(PREF_ACCOUNT_NAME, null);
  if (accountName == null || accountName.isEmpty()) {
    // If you haven't set up an account yet, then we can't sync anyway.
    Log.w(TAG, "No account set, cannot sync!");
    return;
  }

  boolean hasGetAccountsPermission = ContextCompat.checkSelfPermission(
      context, Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED;
  if (!hasGetAccountsPermission) {
    Log.w(TAG, "Don't have GET_ACCOUNTS permission, can't sync.");
    return;
  }

  Log.d(TAG, "Using account: " + accountName);
  credential.setSelectedAccountName(accountName);

  Syncsteps.Builder builder = new Syncsteps.Builder(
      AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential);
  builder.setApplicationName("Steptastic");
  new StepSyncer(context, builder.build(), fullSync).sync();
}
 
开发者ID:codeka,项目名称:steptastic,代码行数:27,代码来源:StepSyncer.java

示例4: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
@Override
protected CollectionResponseCategory doInBackground(Void... params) {


	Categoryendpoint.Builder endpointBuilder = new Categoryendpoint.Builder(
      AndroidHttp.newCompatibleTransport(), new JacksonFactory(), null);
 
  endpointBuilder = CloudEndpointUtils.updateBuilder(endpointBuilder);


  CollectionResponseCategory result;

  Categoryendpoint endpoint = endpointBuilder.build();

  try {
    result = endpoint.listCategory().execute();
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    result = null;
  }
  return result;
}
 
开发者ID:ljug,项目名称:gestionDepenseMobile,代码行数:24,代码来源:ExpenseFormActivity.java

示例5: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
/**
 * Calls appropriate CloudEndpoint to indicate that user checked into a place.
 *
 * @param params the place where the user is checking in.
 */
@Override
protected Void doInBackground(Void... params) {
  CheckIn checkin = new com.google.samplesolutions.mobileassistant.checkinendpoint.model.CheckIn();

  // Set the ID of the store where the user is.
  checkin.setPlaceId("StoreNo123");

  Checkinendpoint.Builder builder = new Checkinendpoint.Builder(
      AndroidHttp.newCompatibleTransport(), new JacksonFactory(), null);

  builder = CloudEndpointUtils.updateBuilder(builder);

  Checkinendpoint endpoint = builder.build();


  try {
    endpoint.insertCheckIn(checkin).execute();
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }

  return null;
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-backend-java,代码行数:30,代码来源:MainActivity.java

示例6: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {


	Incomeendpoint.Builder endpointBuilder = new Incomeendpoint.Builder(
      AndroidHttp.newCompatibleTransport(), new JacksonFactory(), null);
 
  endpointBuilder = CloudEndpointUtils.updateBuilder(endpointBuilder);

  Incomeendpoint endpoint = endpointBuilder.build();

  try {
    endpoint.removeIncome(currentIncome.getKey().getId().longValue()).execute();
				
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();        
  }
  return null;
}
 
开发者ID:ljug,项目名称:gestionDepenseMobile,代码行数:21,代码来源:IncomeActivity.java

示例7: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
protected Long doInBackground(Context... contexts) {

			Messageendpoint.Builder endpointBuilder = new Messageendpoint.Builder(
					AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
					credential);
			endpointBuilder.setApplicationName(getString(R.string.app_name));

			Messageendpoint endpoint = CloudEndpointUtils.updateBuilder(
					endpointBuilder).build();
			try {
				endpoint.updateMessageText(line.msgId,line.data).execute();
				
				
			} catch (IOException e) {
				e.printStackTrace();
			}
			return (long) 0;
		}
 
开发者ID:sajiddalvi,项目名称:guruslist,代码行数:19,代码来源:MessageEditActivity.java

示例8: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
@Override
protected CollectionResponseExpense doInBackground(Void... params) {


	Expenseendpoint.Builder endpointBuilder = new Expenseendpoint.Builder(
      AndroidHttp.newCompatibleTransport(), new JacksonFactory(), null);
 
  endpointBuilder = CloudEndpointUtils.updateBuilder(endpointBuilder);


  CollectionResponseExpense result;

  Expenseendpoint endpoint = endpointBuilder.build();

  try {
    result = endpoint.listExpense().execute();
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    result = null;
  }
  return result;
}
 
开发者ID:ljug,项目名称:gestionDepenseMobile,代码行数:24,代码来源:ExpenseListActivity.java

示例9: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
protected Long doInBackground(Context... contexts) {

			Messageendpoint.Builder endpointBuilder = new Messageendpoint.Builder(
					AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
					credential);

			Messageendpoint endpoint = CloudEndpointUtils.updateBuilder(
					endpointBuilder).build();
			try {
				endpoint.removeMessagesForList(deleteListId).execute();
			} catch (IOException e) {
				e.printStackTrace();
				progress.dismiss();
			}
			return (long) 0;
		}
 
开发者ID:sajiddalvi,项目名称:guruslist,代码行数:17,代码来源:DisplayListActivity.java

示例10: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
protected Long doInBackground(Context... contexts) {

			Messageendpoint.Builder endpointBuilder = new Messageendpoint.Builder(
					AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
					credential);
			endpointBuilder.setApplicationName(getString(R.string.app_name));

			Messageendpoint endpoint = CloudEndpointUtils.updateBuilder(
					endpointBuilder).build();

			try {
				msgs = endpoint.listMyMessage().setConvid(this.convId)
						.execute();

			} catch (IOException e) {
				e.printStackTrace();
			}
			return (long) 0;
		}
 
开发者ID:sajiddalvi,项目名称:guruslist,代码行数:20,代码来源:ListDetailActivity.java

示例11: doInBackground

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
/**
 * Calls appropriate CloudEndpoint to indicate that user checked into a place.
 *
 * @param params the place where the user is checking in.
 */
@Override
protected Void doInBackground(PlaceInfo... params) {

  CheckIn checkin = new CheckIn();
  checkin.setPlaceId(params[0].getPlaceId());

  Builder endpointBuilder = new Shoppingassistant.Builder(
      AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
      CloudEndpointBuilderHelper.getRequestInitializer());

  CheckInEndpoint checkinEndpoint =
      CloudEndpointBuilderHelper.updateBuilder(endpointBuilder).build().checkInEndpoint();

  try {
    checkinEndpoint.insert(checkin).execute();
  } catch (IOException e) {
    String message = e.getMessage();
    if (message == null) {
      message = e.toString();
    }
    log.warning("Exception when checking in =" + message);
  }
  return null;
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-android-client,代码行数:30,代码来源:MainActivity.java

示例12: onCreate

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
/**
 * Called when the activity is first created. It displays the UI, checks
 * for the account previously chosen to sign in (if available), and
 * configures the service object.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  settings = getSharedPreferences(TAG, 0);
  credential = GoogleAccountCredential.usingAudience(this, ClientCredentials.AUDIENCE);
  setAccountName(settings.getString(PREF_ACCOUNT_NAME, null));

  Tictactoe.Builder builder = new Tictactoe.Builder(
      AndroidHttp.newCompatibleTransport(), new GsonFactory(),
      credential);
  service = builder.build();

  if (credential.getSelectedAccountName() != null) {
    onSignIn();
  }

  Logger.getLogger("com.google.api.client").setLevel(LOGGING_LEVEL);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-endpoints-tictactoe-android,代码行数:26,代码来源:TictactoeActivity.java

示例13: CalendarRequestTask

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
public CalendarRequestTask(GoogleAccountCredential credential) {
    mCredential = credential;
    HttpTransport transport = AndroidHttp.newCompatibleTransport();
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    mService = new com.google.api.services.calendar.Calendar.Builder(
            transport, jsonFactory, credential)
            .setApplicationName("Family Calendar")
            .build();
}
 
开发者ID:ITVlab,项目名称:Family-Calendar,代码行数:10,代码来源:CalendarRequestTask.java

示例14: MakeGETRequestTask

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
MakeGETRequestTask(GoogleAccountCredential credential) {
    HttpTransport transport = AndroidHttp.newCompatibleTransport();
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    mService = new com.google.api.services.sheets.v4.Sheets.Builder(
            transport, jsonFactory, credential)
            .setApplicationName("Homework Manager")
            .build();
}
 
开发者ID:Pl4gue,项目名称:homeworkManager-android,代码行数:9,代码来源:GetHomeworkPresenter.java

示例15: MakePOSTRequestTask

import com.google.api.client.extensions.android.http.AndroidHttp; //导入方法依赖的package包/类
MakePOSTRequestTask(GoogleAccountCredential credential) {
    HttpTransport transport = AndroidHttp.newCompatibleTransport();
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    mService = new com.google.api.services.sheets.v4.Sheets.Builder(
            transport, jsonFactory, credential)
            .setApplicationName("Homework Manager")
            .build();
}
 
开发者ID:Pl4gue,项目名称:homeworkManager-android,代码行数:9,代码来源:AddHomeworkPresenter.java


注:本文中的com.google.api.client.extensions.android.http.AndroidHttp.newCompatibleTransport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。