下面列出了android.content.IntentSender.SendIntentException#com.google.android.gms.drive.Drive 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public SyncService initialize(Activity context) {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
.requestScopes(Drive.SCOPE_APPFOLDER)
//.requestScopes(Games.SCOPE_GAMES)
.build();
mGoogleSignClient = GoogleSignIn.getClient(context, gso);
mSignInAccount = GoogleSignIn.getLastSignedInAccount(context);
return this;
}
/**
* Starts the sign-in process and initializes the Drive client.
*/
protected void signIn() {
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)) {
initializeDriveClient(signInAccount);
} else {
GoogleSignInOptions signInOptions =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(Drive.SCOPE_FILE)
.requestScopes(Drive.SCOPE_APPFOLDER)
.build();
GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(this, signInOptions);
startActivityForResult(googleSignInClient.getSignInIntent(), REQUEST_CODE_SIGN_IN);
}
}
private void initializePlayGameServices(boolean enableSaveGamesFunctionality) {
GoogleSignInOptions signInOptions = null;
if (enableSaveGamesFunctionality) {
GoogleSignInOptions.Builder signInOptionsBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
signInOptionsBuilder.requestScopes(Drive.SCOPE_APPFOLDER).requestId();
signInOptions = signInOptionsBuilder.build();
} else {
signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN;
}
godotCallbacksUtils = new GodotCallbacksUtils();
connectionController = new ConnectionController(appActivity, signInOptions, godotCallbacksUtils);
signInController = new SignInController(appActivity, godotCallbacksUtils, connectionController);
achievementsController = new AchievementsController(appActivity, connectionController, godotCallbacksUtils);
leaderboardsController = new LeaderboardsController(appActivity, godotCallbacksUtils, connectionController);
eventsController = new EventsController(appActivity, connectionController, godotCallbacksUtils);
playerStatsController = new PlayerStatsController(appActivity, connectionController, godotCallbacksUtils);
savedGamesController = new SavedGamesController(appActivity, godotCallbacksUtils, connectionController);
googleSignInClient = GoogleSignIn.getClient(appActivity, signInOptions);
}
/**
* Initializes the GoogleApiClient. Give your main AndroidLauncher as context.
* <p>
* Don't forget to add onActivityResult method there with call to onGpgsActivityResult.
*
* @param context your AndroidLauncher class
* @param enableDriveAPI true if you activate save gamestate feature
* @return this for method chunking
*/
public GpgsClient initialize(Activity context, boolean enableDriveAPI) {
if (mGoogleApiClient != null)
throw new IllegalStateException("Already initialized.");
myContext = context;
// retry some times when connect fails (needed when game state sync is enabled)
firstConnectAttempt = MAX_CONNECTFAIL_RETRIES;
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(myContext)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES);
driveApiEnabled = enableDriveAPI;
if (driveApiEnabled)
builder.addScope(Drive.SCOPE_APPFOLDER);
// add other APIs and scopes here as needed
mGoogleApiClient = builder.build();
return this;
}
private ConnectionResult connect() throws ImportExportException {
if (googleApiClient == null) {
String googleDriveAccount = MyPreferences.getGoogleDriveAccount(context);
if (googleDriveAccount == null) {
throw new ImportExportException(R.string.google_drive_account_required);
}
googleApiClient = new GoogleApiClient.Builder(context)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.setAccountName(googleDriveAccount)
//.addConnectionCallbacks(this)
//.addOnConnectionFailedListener(this)
.build();
}
return googleApiClient.blockingConnect(1, TimeUnit.MINUTES);
}
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void doRestore(DoDriveRestore event) {
try {
ConnectionResult connectionResult = connect();
if (connectionResult.isSuccess()) {
DriveFile file = Drive.DriveApi.getFile(googleApiClient, event.selectedDriveFile.driveId);
DriveApi.DriveContentsResult contentsResult = file.open(googleApiClient, DriveFile.MODE_READ_ONLY, null).await();
if (contentsResult.getStatus().isSuccess()) {
DriveContents contents = contentsResult.getDriveContents();
try {
DatabaseImport.createFromGoogleDriveBackup(context, db, contents).importDatabase();
bus.post(new DriveRestoreSuccess());
} finally {
contents.discard(googleApiClient);
}
} else {
handleFailure(contentsResult.getStatus());
}
} else {
handleConnectionResult(connectionResult);
}
} catch (Exception e) {
handleError(e);
}
}
private Status createFile(DriveFolder folder, String fileName, byte[] bytes) throws IOException {
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(fileName)
.setMimeType(Export.BACKUP_MIME_TYPE).build();
// Create a file in the root folder
DriveApi.DriveContentsResult contentsResult = Drive.DriveApi.newDriveContents(googleApiClient).await();
Status contentsResultStatus = contentsResult.getStatus();
if (contentsResultStatus.isSuccess()) {
DriveContents contents = contentsResult.getDriveContents();
contents.getOutputStream().write(bytes);
DriveFolder.DriveFileResult fileResult = folder.createFile(googleApiClient, changeSet, contents).await();
return fileResult.getStatus();
} else {
return contentsResultStatus;
}
}
/**
* Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
* you do not have to do this; use this method only if you need to make
* nonstandard setup (e.g. adding extra scopes for other APIs) on the
* GoogleApiClient.Builder before calling @link{#setup}.
*/
public GoogleApiClient.Builder createApiClientBuilder() {
if (mSetupDone) {
String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
+ "calling setup. You can only get a client builder BEFORE performing setup.";
logError(error);
throw new IllegalStateException(error);
}
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
mActivity, this, this);
if (0 != (mRequestedClients & CLIENT_GAMES)) {
builder.addApi(Games.API, mGamesApiOptions);
builder.addScope(Games.SCOPE_GAMES);
}
if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
builder.addScope(Drive.SCOPE_APPFOLDER);
builder.addApi(Drive.API);
}
mGoogleApiClientBuilder = builder;
return builder;
}
private void readFileFromGoogleDrive(){
if (mGoogleApiClient !=null && mGoogleApiClient.isConnected()){
// Let the user pick text file
// no files selected by the user.
//http://stackoverflow.com/questions/26331046/android-how-can-i-access-a-spreadsheet-with-the-google-drive-sdk
// cannot open google doc file
IntentSender intentSender = Drive.DriveApi
.newOpenFileActivityBuilder()
.setMimeType(new String[]{"text/plain", "application/vnd.google-apps.document"})
.build(mGoogleApiClient);
try {
startIntentSenderForResult(intentSender, GDRIVE_REQUEST_CODE_OPENER, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.w(TAG, "Unable to send intent", e);
}
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create the progress dialog view - displayed when connecting to Google APIs.
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Connecting to Google APIs...");
progressDialog.setIndeterminate(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setCancelable(false);
// Create the connection driveClient.
driveClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
public void onResult(DriveApi.DriveContentsResult result) {
MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
.setTitle("cumulustv_channels.json")
.setDescription("JSON list of channels that can be imported using CumulusTV to view live streams")
.setMimeType("application/json").build();
IntentSender intentSender = Drive.DriveApi
.newCreateFileActivityBuilder()
.setActivityTitle("cumulustv_channels.json")
.setInitialMetadata(metadataChangeSet)
.setInitialDriveContents(result.getDriveContents())
.build(CloudStorageProvider.getInstance().getClient());
try {
mActivity.startIntentSenderForResult(
intentSender, REQUEST_CODE_CREATOR, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.w(TAG, "Unable to send intent", e);
}
}
public static void createDriveData(Activity activity, GoogleApiClient gapi,
final ResultCallback<DriveApi.DriveContentsResult> driveContentsCallback) {
PermissionUtils.requestPermissionIfDisabled(activity,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
activity.getString(R.string.permission_storage_rationale));
if(gapi == null)
gapi = mCloudStorageProvider.connect(activity);
try {
final GoogleApiClient finalGapi = gapi;
new AlertDialog.Builder(activity)
.setTitle(R.string.create_sync_file_title)
.setMessage(R.string.create_sync_file_description)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Drive.DriveApi.newDriveContents(finalGapi)
.setResultCallback(driveContentsCallback);
}
})
.setNegativeButton(R.string.no, null)
.show();
} catch(Exception ignored) {
Toast.makeText(activity, "Error creating drive data: " + ignored.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onResult(DriveApi.DriveContentsResult result) {
MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
.setTitle("cumulustv_channels.json")
.setDescription("JSON list of channels that can be imported using " +
"CumulusTV to view live streams")
.setMimeType("application/json").build();
IntentSender intentSender = Drive.DriveApi
.newCreateFileActivityBuilder()
.setActivityTitle("cumulustv_channels.json")
.setInitialMetadata(metadataChangeSet)
.setInitialDriveContents(result.getDriveContents())
.build(CloudStorageProvider.getInstance().getClient());
try {
startIntentSenderForResult(
intentSender, REQUEST_CODE_CREATOR, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.w(TAG, "Unable to send intent", e);
}
}
@DebugLog
@Override
public void onResume() {
super.onResume();
EventBus.getDefault().register(this);
if (SyncService.getInstance() != null)
mGoogleApiClient = SyncService.getInstance().getClient();
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
SyncService.getInstance().setGoogleApiClient(mGoogleApiClient);
}
}
@DebugLog
private void createAmiiboFolder() {
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(AMIIBO_FOLDER).build();
Drive.DriveApi.getRootFolder(_parent.getClient())
.createFolder(_parent.getClient(), changeSet)
.setResultCallback(new ResultCallback<DriveFolder.DriveFolderResult>() {
@Override
public void onResult(DriveFolder.DriveFolderResult driveFolderResult) {
if (driveFolderResult.getStatus().isSuccess()) {
app_folder_for_user = driveFolderResult.getDriveFolder();
listFiles();
} else {
app_folder_for_user = null;
_parent.onPushFinished();
}
}
});
}
@DebugLog
private void readFileFromDrive(final MetadataBuffer meta_data, final DriveId drive_id) {
Drive.DriveApi.getFile(_parent.getClient(), drive_id)
.open(_parent.getClient(), DriveFile.MODE_READ_ONLY, null)
.setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
@Override
public void onResult(DriveApi.DriveContentsResult driveContentsResult) {
try {
InputStream input = driveContentsResult.getDriveContents()
.getInputStream();
String total = consumeStream(input);
AmiiboFile amiibo_file = AmiiboFile.fromString(total.toString());
_parent.onFileRead(amiibo_file);
if (!meta_data.isClosed()) meta_data.release();
} catch (IOException e) {
e.printStackTrace();
_parent.onFileRead(null);
}
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
log("onCreate.");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the client used to sign in.
mGoogleSignInClient = GoogleSignIn.getClient(this,
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
// Since we are using SavedGames, we need to add the SCOPE_APPFOLDER to access Google Drive.
.requestScopes(Drive.SCOPE_APPFOLDER)
.build());
for (int id : LEVEL_BUTTON_IDS) {
findViewById(id).setOnClickListener(this);
}
findViewById(R.id.button_next_world).setOnClickListener(this);
findViewById(R.id.button_prev_world).setOnClickListener(this);
findViewById(R.id.button_sign_in).setOnClickListener(this);
findViewById(R.id.button_sign_out).setOnClickListener(this);
((RatingBar) findViewById(R.id.gameplay_rating)).setOnRatingBarChangeListener(this);
mSaveGame = new SaveGame();
updateUi();
checkPlaceholderIds();
}
private void signIn(boolean requestEmail, boolean scopeSnapshot) {
GoogleSignInOptions.Builder builder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
if (requestEmail) {
builder.requestEmail();
}
if (scopeSnapshot) {
builder.requestScopes(Drive.SCOPE_APPFOLDER);
}
GoogleSignInOptions opts = builder.build();
GoogleSignInClient signInClient = GoogleSignIn.getClient(registrar.activity(), opts);
silentSignIn(signInClient);
}
/**
* Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
* you do not have to do this; use this method only if you need to make
* nonstandard setup (e.g. adding extra scopes for other APIs) on the
* GoogleApiClient.Builder before calling @link{#setup}.
*/
public GoogleApiClient.Builder createApiClientBuilder() {
if (mSetupDone) {
String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
+ "calling setup. You can only get a client builder BEFORE performing setup.";
logError(error);
throw new IllegalStateException(error);
}
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
mActivity, this, this);
if (0 != (mRequestedClients & CLIENT_GAMES)) {
builder.addApi(Games.API, mGamesApiOptions);
builder.addScope(Games.SCOPE_GAMES);
}
if (0 != (mRequestedClients & CLIENT_PLUS)) {
builder.addApi(Plus.API);
builder.addScope(Plus.SCOPE_PLUS_LOGIN);
}
if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
builder.addScope(Drive.SCOPE_APPFOLDER);
builder.addApi(Drive.API);
}
mGoogleApiClientBuilder = builder;
return builder;
}
private DriveFolder getOrCreateDriveFolder(String targetFolder) throws IOException {
Query query = new Query.Builder().addFilter(Filters.and(
Filters.eq(SearchableField.TRASHED, false),
Filters.eq(SearchableField.TITLE, targetFolder),
Filters.eq(SearchableField.MIME_TYPE, "application/vnd.google-apps.folder")
)).build();
DriveApi.MetadataBufferResult result = Drive.DriveApi.query(googleApiClient, query).await();
if (result.getStatus().isSuccess()) {
DriveId driveId = fetchDriveId(result);
if (driveId != null) {
return Drive.DriveApi.getFolder(googleApiClient, driveId);
}
}
return createDriveFolder(targetFolder);
}
private DriveFolder createDriveFolder(String targetFolder) {
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(targetFolder).build();
DriveFolder.DriveFolderResult result = Drive.DriveApi.getRootFolder(googleApiClient).createFolder(googleApiClient, changeSet).await();
if (result.getStatus().isSuccess()) {
return result.getDriveFolder();
} else {
return null;
}
}
/**
* Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
* you do not have to do this; use this method only if you need to make
* nonstandard setup (e.g. adding extra scopes for other APIs) on the
* GoogleApiClient.Builder before calling @link{#setup}.
*/
public GoogleApiClient.Builder createApiClientBuilder() {
if (mSetupDone) {
String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
+ "calling setup. You can only get a client builder BEFORE performing setup.";
logError(error);
throw new IllegalStateException(error);
}
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
mActivity, this, this);
if (0 != (mRequestedClients & CLIENT_GAMES)) {
builder.addApi(Games.API, mGamesApiOptions);
builder.addScope(Games.SCOPE_GAMES);
}
if (0 != (mRequestedClients & CLIENT_PLUS)) {
builder.addApi(Plus.API);
builder.addScope(Plus.SCOPE_PLUS_LOGIN);
}
if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
builder.addScope(Drive.SCOPE_APPFOLDER);
builder.addApi(Drive.API);
}
mGoogleApiClientBuilder = builder;
return builder;
}
public GoogleApiClient getGoogleApiClient() {
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addOnConnectionFailedListener(this)
.build();
}
return mGoogleApiClient;
}
private GoogleApiClient getGoogleApiClient() {
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
return mGoogleApiClient;
}
private void createLogInFolder() {
// create new contents resource
if (folderDriveId == null)
exitUploadFailed();
else
Drive.DriveApi.newDriveContents(getGoogleApiClient())
.setResultCallback(createLogInFolderCallback);
}
public void init() {
googleApiClient = new GoogleApiClient.Builder(activity).addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle bundle) {
gpgs.setClient(googleApiClient);
GodotLib.calldeferred(instance_id, "_on_google_play_game_services_connected", new Object[] { });
Log.d(TAG, "GPGS: onConnected");
}
@Override
public void onConnectionSuspended(int cause) {
if (cause == GoogleApiClient.ConnectionCallbacks.CAUSE_NETWORK_LOST) {
GodotLib.calldeferred(instance_id, "_on_google_play_game_services_suspended_network_lost", new Object[] { });
Log.d(TAG, "GPGS: onConnectionSuspended -> Network Lost");
} else if (cause == GoogleApiClient.ConnectionCallbacks.CAUSE_SERVICE_DISCONNECTED) {
GodotLib.calldeferred(instance_id, "_on_google_play_game_services_suspended_service_disconnected", new Object[] { });
Log.d(TAG, "GPGS: onConnectionSuspended -> Service Disconnected");
} else {
GodotLib.calldeferred(instance_id, "_on_google_play_game_services_suspended_unknown", new Object[] { });
Log.d(TAG, "GPGS: onConnectionSuspended -> Unknown");
}
}
}).addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.i(TAG, "GPGS: onConnectionFailed result code: " + String.valueOf(result));
if (isResolvingConnectionFailure) return; // Already resolving
isResolvingConnectionFailure = true;
if (!resolveConnectionFailure(result, REQUEST_RESOLVE_ERROR)) {
isResolvingConnectionFailure = false;
}
}
})
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
.addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER)
.build();
GodotLib.calldeferred(instance_id, "_on_google_play_game_services_initiated", new Object[] { });
}
public void connectToDrive(boolean backup) {
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(activity);
if (account == null) {
signIn();
} else {
//Initialize the drive api
mDriveClient = Drive.getDriveClient(activity, account);
// Build a drive resource client.
mDriveResourceClient = Drive.getDriveResourceClient(activity, account);
if (backup)
startDriveBackup();
else
startDriveRestore();
}
}
private GoogleSignInClient buildGoogleSignInClient() {
GoogleSignInOptions signInOptions =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(Drive.SCOPE_FILE)
.build();
return GoogleSignIn.getClient(activity, signInOptions);
}
/**
* Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
* you do not have to do this; use this method only if you need to make
* nonstandard setup (e.g. adding extra scopes for other APIs) on the
* GoogleApiClient.Builder before calling @link{#setup}.
*/
public GoogleApiClient.Builder createApiClientBuilder() {
if (mSetupDone) {
String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
+ "calling setup. You can only get a client builder BEFORE performing setup.";
logError(error);
throw new IllegalStateException(error);
}
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
mActivity, this, this);
if (0 != (mRequestedClients & CLIENT_GAMES)) {
builder.addApi(Games.API, mGamesApiOptions);
builder.addScope(Games.SCOPE_GAMES);
}
if (0 != (mRequestedClients & CLIENT_PLUS)) {
builder.addApi(Plus.API);
builder.addScope(Plus.SCOPE_PLUS_LOGIN);
}
if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
builder.addScope(Drive.SCOPE_APPFOLDER);
builder.addApi(Drive.API);
}
mGoogleApiClientBuilder = builder;
return builder;
}
private boolean connectGoogleApiClient(){
if (mGoogleApiClient == null || (!mGoogleApiClient.isConnected())) {
// Create the API client and bind it to an instance variable.
// We use this instance as the callback for connection and connection
// failures.
// Since no account name is passed, the user is prompted to choose.
Log.d(TAG, "creating a new google api client");
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleApiClient.connect();
}
return true;
// ConnectionResult result=mGoogleApiClient.blockingConnect(2000, TimeUnit.MILLISECONDS);
// if (result.isSuccess()){
// return true;
// } else {
// if (!result.hasResolution()) {
// // show the localized error dialog.
// GoogleApiAvailability.getInstance().getErrorDialog(this, result.getErrorCode(), 0).show();
// Log.i(TAG, "trying to resolve" + result.toString());
// } else {
// // The failure has a resolution. Resolve it.
// // Called typically when the app is not yet authorized, and an
// // authorization
// // dialog is displayed to the user.
// try {
// result.startResolutionForResult(this, GDRIVE_RESOLVE_CONNECTION_REQUEST_CODE);
// } catch (IntentSender.SendIntentException e) {
// Log.e(TAG, "Exception while starting resolution activity", e);
// }
// }
// return false;
// }
}