本文整理匯總了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);
}
}
示例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();
}
});
}
示例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;
}
示例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]
}
}
示例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;
}
示例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);
}