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


Java DriveId.decodeFromString方法代碼示例

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


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

示例1: onCreate

import com.google.android.gms.drive.DriveId; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    ButterKnife.bind(this);

    mMainHandler = new Handler();

    mMainHandler.post(new UpdateCurrentTime());

    String driveId = getPreferences(Context.MODE_PRIVATE).getString(DRIVE_ID_FILE, null);

    if (driveId != null) {
        mDriveId = DriveId.decodeFromString(driveId);
    }
}
 
開發者ID:claudiodegio,項目名稱:dbsync,代碼行數:24,代碼來源:BaseMainDbActivity.java

示例2: modifyExistingDriveBackup

import com.google.android.gms.drive.DriveId; //導入方法依賴的package包/類
private void modifyExistingDriveBackup() {
    final DriveId driveId = DriveId.decodeFromString(mDriveId);
    getmDriveResourceClient().openFile(driveId.asDriveFile(), DriveFile.MODE_WRITE_ONLY)
            .continueWithTask(new Continuation<DriveContents, Task<Void>>() {
                @Override
                public Task<Void> then(@NonNull Task<DriveContents> task) throws Exception {
                    DriveContents driveContents = task.getResult();

                    writeBackupToOutputStream(driveContents.getOutputStream());

                    MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
                            .setTitle(BACKUP_FILE_NAME_COMPRESSED)
                            .setMimeType("application/zip")
                            .setCustomProperty(DRIVE_KEY_APP_ID, mAppId)
                            .setCustomProperty(DRIVE_KEY_DEVICE_NAME, DeviceName.getDeviceName())
                            .build();

                    return getmDriveResourceClient().commitContents(driveContents, metadataChangeSet);
                }
            })
            .addOnSuccessListener(new OnSuccessListener<Void>() {
                @Override
                public void onSuccess(Void aVoid) {
                    Log.d(TAG, "Drive file modified " + mDriveId);
                    finishJob(true);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.w(TAG, "Couldn't open drive file. Maybe deleted by user.");
                    mDriveId = null; // Create a new file

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

示例3: CursorToFile

import com.google.android.gms.drive.DriveId; //導入方法依賴的package包/類
private File CursorToFile(Cursor cursor) {
    File file = new File();
    file.id = cursor.getLong(cursor.getColumnIndexOrThrow(DBContracts.FileEntry.COLUMN_NAME_ID));
    if (cursor.getString(cursor.getColumnIndexOrThrow(DBContracts.FileEntry.COLUMN_NAME_DRIVE_ID)) != null)
        file.driveId = DriveId.decodeFromString(cursor.getString(cursor.getColumnIndexOrThrow(DBContracts.FileEntry.COLUMN_NAME_DRIVE_ID)));
    file.fileName = cursor.getString(cursor.getColumnIndexOrThrow(DBContracts.FileEntry.COLUMN_NAME_FILENAME));
    try {
        file.dateViewed = dateFormat.parse(cursor.getString(cursor.getColumnIndexOrThrow(DBContracts.FileEntry.COLUMN_NAME_DATEVIEWED)));
    } catch (Exception e) {
        //e.printStackTrace();
    }
    return file;
}
 
開發者ID:rkkr,項目名稱:drive-notepad,代碼行數:14,代碼來源:FileHelper.java

示例4: deleteSavedEquations

import com.google.android.gms.drive.DriveId; //導入方法依賴的package包/類
/**
 * Deletes the App Data file associated with the {@link DriveId} in {@link SharedPreferences}, if
 * it exists.
 */
private void deleteSavedEquations() {
  final String driveIdStr = mSharedPreferences.getString(DRIVE_ID, null);
  if (driveIdStr != null) {
    DriveId fileId = DriveId.decodeFromString(driveIdStr);

    // [START delete_file]
    // Delete App Data file
    DriveFile sumFile = fileId.asDriveFile();
    mDriveResourceClient.delete(sumFile)
        .addOnSuccessListener(new OnSuccessListener<Void>() {
          @Override
          public void onSuccess(Void aVoid) {
            // Delete completed successfully. UI changes, etc. can now be updated to reflect the
            // change.

            // [START_EXCLUDE]
            // Remove stored DriveId from SharedPreferences
            mSharedPreferences.edit().remove(DRIVE_ID).apply();
            Log.d(TAG, "Past sums deleted.");
            // [END_EXCLUDE]
          }
        })
        .addOnFailureListener(new OnFailureListener() {
          @Override
          public void onFailure(@NonNull Exception e) {
            // Delete was not completed. Inform the user or add failure handling here.

            // [START_EXCLUDE]
            Log.e(TAG, "Unable to delete App Data.", e);
            // [END_EXCLUDE]
          }
        });
    // [END delete_file]
  }
}
 
開發者ID:googledrive,項目名稱:android-delete,代碼行數:40,代碼來源:MainActivity.java

示例5: setSyncFileByString

import com.google.android.gms.drive.DriveId; //導入方法依賴的package包/類
/**
 * Set the to use to sync
 * @param s the drive file as encoded string
 */
public Builder setSyncFileByString(String s) {
    this.mDriveId = DriveId.decodeFromString(s);
    return this;
}
 
開發者ID:claudiodegio,項目名稱:dbsync,代碼行數:9,代碼來源:GDriveCloudProvider.java

示例6: getAppRootFolder

import com.google.android.gms.drive.DriveId; //導入方法依賴的package包/類
/**
 * @return the root folder for this app. All application data should be stored there
 */
public DriveFolder getAppRootFolder() {
	DriveId folderId = DriveId.decodeFromString(appRootFolderIdPref.get());
	return Drive.DriveApi.getFolder(googleApiClientManager.getGoogleApiClient(), folderId);
}
 
開發者ID:FauDroids,項目名稱:BabyFace,代碼行數:8,代碼來源:GoogleDriveManager.java


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