Java 类com.google.android.gms.tasks.RuntimeExecutionException 实例源码

项目:treedo    文件:MainActivity.java   
public void enableBackup() {
    if (!isConnected()) {
        snackBar(getString(R.string.connection_needed));
    } else if (!isGooglePlayServicesAvailable()) {
        acquireGooglePlayServices();
    } else if (Build.VERSION.SDK_INT >= 23 && !(checkCallingOrSelfPermission(Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED)) {
        requestPermissions(new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSION_RESULT_GET_ACCOUNTS);
    } else if (mService == null) {
        chooseAccount();
    } else if (mFileId == null) {
        Async.start(() -> {
            try {
                File file = new File();
                file.setName(mFileName);
                file.setMimeType("application/json");
                File result = mService.files().create(file).setFields("id").execute();
                return result.getId();
            } catch (IOException e) {
                throw new RuntimeExecutionException(e);
            }
        }).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mEnableBackupSubscriber);
    }
}