android.content.IntentSender.SendIntentException#com.google.android.gms.drive.Drive源码实例Demo

下面列出了android.content.IntentSender.SendIntentException#com.google.android.gms.drive.Drive 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Passbook   文件: GameSyncService.java
@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;
}
 
源代码2 项目: android-samples   文件: BaseDemoActivity.java
/**
 * 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);
    }
}
 
源代码3 项目: PGSGP   文件: PlayGameServices.java
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);
}
 
源代码4 项目: gdx-gamesvcs   文件: GpgsClient.java
/**
 * 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;
}
 
源代码5 项目: financisto   文件: GoogleDriveClient.java
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);
}
 
源代码6 项目: financisto   文件: GoogleDriveClient.java
@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);
    }
}
 
源代码7 项目: financisto   文件: GoogleDriveClient.java
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;
    }
}
 
源代码8 项目: dice-heroes   文件: GameHelper.java
/**
 * 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;
}
 
源代码9 项目: faceswap   文件: CloudletDemoActivity.java
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);
        }
    }
}
 
源代码10 项目: biermacht   文件: DriveActivity.java
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();
  }
 
源代码11 项目: CumulusTV   文件: LeanbackFragment.java
@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);
    }
}
 
源代码12 项目: CumulusTV   文件: ActivityUtils.java
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();
    }
}
 
源代码13 项目: CumulusTV   文件: MainActivity.java
@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);
    }
}
 
源代码14 项目: amiibo   文件: DriveFragment.java
@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);
    }

}
 
源代码15 项目: amiibo   文件: FileManager.java
@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();
                    }
                }
            });
}
 
源代码16 项目: amiibo   文件: FileManager.java
@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);
                    }
                }
            });
}
 
源代码17 项目: android-basic-samples   文件: MainActivity.java
@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();
}
 
源代码18 项目: play_games   文件: PlayGamesPlugin.java
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);
}
 
源代码19 项目: Asteroid   文件: GameHelper.java
/**
 * 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;
}
 
源代码20 项目: financisto   文件: GoogleDriveClient.java
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);
}
 
源代码21 项目: financisto   文件: GoogleDriveClient.java
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;
    }
}
 
源代码22 项目: Trivia-Knowledge   文件: GameHelper.java
/**
 * 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;
}
 
源代码23 项目: WheelLogAndroid   文件: MainActivity.java
public GoogleApiClient getGoogleApiClient() {
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addOnConnectionFailedListener(this)
                .build();
    }
    return mGoogleApiClient;
}
 
源代码24 项目: WheelLogAndroid   文件: GoogleDriveService.java
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;
}
 
源代码25 项目: WheelLogAndroid   文件: GoogleDriveService.java
private void createLogInFolder() {
    // create new contents resource
    if (folderDriveId == null)
        exitUploadFailed();
    else
        Drive.DriveApi.newDriveContents(getGoogleApiClient())
                .setResultCallback(createLogInFolderCallback);
}
 
源代码26 项目: godot-gpgs   文件: Client.java
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[] { });
}
 
源代码27 项目: Database-Backup-Restore   文件: RemoteBackup.java
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();
    }
}
 
源代码28 项目: Database-Backup-Restore   文件: RemoteBackup.java
private GoogleSignInClient buildGoogleSignInClient() {
    GoogleSignInOptions signInOptions =
            new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestScopes(Drive.SCOPE_FILE)
                    .build();
    return GoogleSignIn.getClient(activity, signInOptions);
}
 
源代码29 项目: FixMath   文件: GameHelper.java
/**
 * 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;
}
 
源代码30 项目: faceswap   文件: CloudletDemoActivity.java
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;
//        }
    }