當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。