當前位置: 首頁>>代碼示例>>Java>>正文


Java Drive.getDriveResourceClient方法代碼示例

本文整理匯總了Java中com.google.android.gms.drive.Drive.getDriveResourceClient方法的典型用法代碼示例。如果您正苦於以下問題:Java Drive.getDriveResourceClient方法的具體用法?Java Drive.getDriveResourceClient怎麽用?Java Drive.getDriveResourceClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.drive.Drive的用法示例。


在下文中一共展示了Drive.getDriveResourceClient方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupClient

import com.google.android.gms.drive.Drive; //導入方法依賴的package包/類
/**
 * Set up the Drive API client.
 *
 * @param prefs The SharedPreferences
 * @return Whether the setup was successful
 */
private boolean setupClient(@NonNull SharedPreferences prefs) {
    final GoogleSignInOptions signInOptions =
            new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestScopes(Drive.SCOPE_APPFOLDER)
                    .build();
    final GoogleSignInClient signInClient = GoogleSignIn.getClient(mContext, signInOptions);
    try {
        final GoogleSignInAccount signInAccount = Tasks.await(signInClient.silentSignIn());

        mClient = Drive.getDriveClient(mContext, signInAccount);
        mResourceClient = Drive.getDriveResourceClient(mContext, signInAccount);

        Log.d(TAG, "Connection successful. sync: " + mShouldSync + " media: " + mMediaMounted);

        return true;
    } catch(ExecutionException e) {
        final ApiException result = (ApiException)e.getCause();
        switch(result.getStatusCode()) {
            case GoogleSignInStatusCodes.SIGN_IN_REQUIRED:
            case GoogleSignInStatusCodes.INVALID_ACCOUNT:
                Log.i(TAG, "User not signed in. Disabling photo syncing.");
                prefs.edit().putBoolean(FlavordexApp.PREF_SYNC_PHOTOS, false).apply();
                break;
            case GoogleSignInStatusCodes.API_NOT_CONNECTED:
            case GoogleSignInStatusCodes.NETWORK_ERROR:
            case GoogleSignInStatusCodes.INTERNAL_ERROR:
                Log.i(TAG, "Google Drive service unavailable. Disabling photo syncing.");
                prefs.edit().putBoolean(FlavordexApp.PREF_SYNC_PHOTOS, false).apply();
        }

        Log.w(TAG, "Connection failed! Reason: " + result.getMessage());
    } catch(InterruptedException ignored) {
    }

    return false;
}
 
開發者ID:ultramega,項目名稱:flavordex,代碼行數:43,代碼來源:PhotoSyncHelper.java

示例2: loadDriveApiClients

import com.google.android.gms.drive.Drive; //導入方法依賴的package包/類
private boolean loadDriveApiClients() {
    Set<Scope> requiredScopes = new HashSet<>(2);
    requiredScopes.add(Drive.SCOPE_FILE);
    requiredScopes.add(Drive.SCOPE_APPFOLDER);

    GoogleSignInAccount signInAccount = GoogleSignIn.getLastSignedInAccount(this);
    if (signInAccount != null && signInAccount.getGrantedScopes().containsAll(requiredScopes)) {
        mDriveClient = Drive.getDriveClient(getApplicationContext(), signInAccount);
        mDriveResourceClient = Drive.getDriveResourceClient(getApplicationContext(), signInAccount);

        return true;
    }

    return false;
}
 
開發者ID:canyapan,項目名稱:DietDiaryApp,代碼行數:16,代碼來源:DriveBackupService.java

示例3: initializeDriveClient

import com.google.android.gms.drive.Drive; //導入方法依賴的package包/類
private void initializeDriveClient(GoogleSignInAccount signInAccount) {
    mDriveClient = Drive.getDriveClient(getContext(), signInAccount);
    mDriveResourceClient = Drive.getDriveResourceClient(getContext(), signInAccount);

    onDriveClientReady();
}
 
開發者ID:canyapan,項目名稱:DietDiaryApp,代碼行數:7,代碼來源:SettingsSupportFragment.java

示例4: createDriveResourceClient

import com.google.android.gms.drive.Drive; //導入方法依賴的package包/類
/**
 * Creates the {@link DriveResourceClient} that is used in order to modify the App Data file.
 */
private void createDriveResourceClient(GoogleSignInAccount account) {
  Log.i(TAG, "Creating DriveResourceClient.");
  mDriveResourceClient = Drive.getDriveResourceClient(getApplicationContext(), account);
}
 
開發者ID:googledrive,項目名稱:android-delete,代碼行數:8,代碼來源:MainActivity.java

示例5: initializeDriveClient

import com.google.android.gms.drive.Drive; //導入方法依賴的package包/類
/**
 * Continues the sign-in process, initializing the DriveResourceClient with the current
 * user's account.
 */
private void initializeDriveClient(GoogleSignInAccount signInAccount) {
    mDriveClient = Drive.getDriveClient(getApplicationContext(), signInAccount);
    mDriveResourceClient = Drive.getDriveResourceClient(getApplicationContext(), signInAccount);
    onDriveClientReady();
}
 
開發者ID:googledrive,項目名稱:android-conflict,代碼行數:10,代碼來源:BaseDemoActivity.java

示例6: initializeDriveResourceClient

import com.google.android.gms.drive.Drive; //導入方法依賴的package包/類
/**
 * Continues the sign-in process, initializing the DriveResourceClient with the current
 * user's account.
 *
 * @param signInAccount Authorized google account
 */
private void initializeDriveResourceClient(GoogleSignInAccount signInAccount) {
    mDriveResourceClient = Drive.getDriveResourceClient(getApplicationContext(), signInAccount);
    onDriveClientReady();
}
 
開發者ID:googledrive,項目名稱:android-trash,代碼行數:11,代碼來源:MainActivity.java


注:本文中的com.google.android.gms.drive.Drive.getDriveResourceClient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。