当前位置: 首页>>代码示例>>Java>>正文


Java Auth.startOAuth2Authentication方法代码示例

本文整理汇总了Java中com.dropbox.core.android.Auth.startOAuth2Authentication方法的典型用法代码示例。如果您正苦于以下问题:Java Auth.startOAuth2Authentication方法的具体用法?Java Auth.startOAuth2Authentication怎么用?Java Auth.startOAuth2Authentication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.dropbox.core.android.Auth的用法示例。


在下文中一共展示了Auth.startOAuth2Authentication方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: syncWorldToDropbox

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
/**
 * Syncs the current World's files to the user's Dropbox account.
 *
 * <p>
 *     If the user has not yet linked a Dropbox account, they will be asked to authenticate
 *     their account.
 * </p>
 *
 * <p>
 *     If an error occurs while syncing files, a message will be displayed.
 * </p>
 */
private void syncWorldToDropbox() {
    if (!(AppPreferences.dropboxAccessTokenExists(this))) {
        Auth.startOAuth2Authentication(getApplicationContext(), DROPBOX_APP_KEY);
        // Since the Authentication Activity interrupts the flow of this method,
        // the actual syncing should occur when the user returns to this Activity after
        // authentication.
        syncWorldToDropboxOnResume = true;
    } else {
        new AlertDialog.Builder(this)
                .setTitle(this.getString(R.string.confirmBackupToDropboxTitle, worldName))
                .setMessage(this.getString(R.string.confirmBackupToDropbox, worldName))
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                    String accessToken = getDropboxAccessToken();
                    DbxClientV2 client = getDropboxClient(accessToken);
                    File worldDirectory = FileRetriever.getWorldDirectory(worldName);
                    new UploadToDropboxTask(client, worldDirectory, ArticleListActivity.this).execute();
                    }})
                .setNegativeButton(android.R.string.no, null).show();
    }
}
 
开发者ID:MarquisLP,项目名称:World-Scribe,代码行数:36,代码来源:ArticleListActivity.java

示例2: onCreate

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        // Toggle link/unlink depending on current state
        if (preferences.contains(DropboxSyncController.ACCESS_TOKEN)) {
            // Show confirmation dialog, action occurs in call-back implementations below
            final ConfirmSyncUnlinkFragment dialog = new ConfirmSyncUnlinkFragment();
            dialog.setController(ControllerImpl.DROPBOX);

            dialog.show(getFragmentManager(), null);
        } else
            Auth.startOAuth2Authentication(this, getString(R.string.dropbox_appkey));
    }
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:17,代码来源:ConfigureDropboxSyncActivity.java

示例3: resumeGetAuthToken

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
private void resumeGetAuthToken(FileStorageSetupActivity activity) {
    FileStorageSetupActivity storageSetupAct = activity;

    if (storageSetupAct.getState().containsKey("hasStartedAuth")) {
        Log.d("KP2AJ", "auth started");

        String v2Token = Auth.getOAuth2Token();


        if (v2Token != null) {
            Log.d("KP2AJ", "auth successful");
            try {
                storeKey(v2Token);
                buildSession();
                finishActivityWithSuccess(activity);
                return;

            } catch (Exception e) {
                Log.d("KP2AJ", "finish with error: " + e.toString());
                finishWithError(activity, e);
                return;
            }
        }


        Log.i(TAG, "authenticating not succesful");
        Intent data = new Intent();
        data.putExtra(EXTRA_ERROR_MESSAGE, "authenticating not succesful");
        ((Activity) activity).setResult(Activity.RESULT_CANCELED, data);
        ((Activity) activity).finish();
    } else {
        Log.d("KP2AJ", "Starting auth");
        Auth.startOAuth2Authentication((Activity) activity, appInfo.getKey());
        storageSetupAct.getState().putBoolean("hasStartedAuth", true);

    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:38,代码来源:DropboxV2Storage.java

示例4: login

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@Override
public void login() {
    Logger.info(this, "login()");
    if (!this.isAuthenticated()) {
        Logger.verbose(this, "login():!Authenticated");
        Auth.startOAuth2Authentication(serviceManager.getContext(), appKey());
    }
}
 
开发者ID:sbs20,项目名称:filenotes-android,代码行数:9,代码来源:DropboxService.java

示例5: startAuth

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
/**
 * start the authentication process. If the user is already
 * logged in, the method returns immediately. If not,
 * a dropbox activity is launched and the caller will need
 * to call {@ref finishAuth} in its onResume.
 *
 * @param callingActivity the calling activity
 * @return true (immediate) if already authentified, won't
 * return but will launch the OAuth process otherwise.
 */
public boolean startAuth(Context callingActivity) {
    String accessToken = getAccessToken();
    if (accessToken == null) {
        Auth.startOAuth2Authentication(this, getString(R.string.app_key));
        return false;
    } else {
        initializeClient(accessToken);
        return true;
    }

}
 
开发者ID:derlin,项目名称:mybooks-android,代码行数:22,代码来源:BaseDboxService.java

示例6: onOptionsItemSelected

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case R.id.menu_add:
            final ProgressDialog progressDialog = ProgressDialog.show(BackupList.this, "",
                    getResources().getString(R.string.lbl_please_wait), true);

            Runnable callback = new Runnable() {
                @Override
                public void run() {
                    progressDialog.cancel();
                    updateContent();
                    loadDriveContents(false);
                }
            };

            if (mDbxClient != null)
                new DropboxBackuper(getApplicationContext(), callback).run();
            else {
                progressDialog.cancel();
                Auth.startOAuth2Authentication(BackupList.this, DropboxConfig.appKey);
            }
            break;

        case R.id.menu_refresh:
            mDriveContents = null;
            updateContent();
            loadDriveContents(true);
            break;

    }

    return false;
}
 
开发者ID:jwdroid,项目名称:jwdroid,代码行数:35,代码来源:BackupList.java

示例7: tryConnect

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public boolean tryConnect(Activity activity)
{
    if (!mLoggedIn)
        Auth.startOAuth2Authentication(activity, appInfo.getKey());
    return mLoggedIn;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:7,代码来源:DropboxV2Storage.java

示例8: beginAuthentication

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public void beginAuthentication(Activity activity) {
    tryLinking = true;
    Auth.startOAuth2Authentication(activity, BuildConfig.DROPBOX_APP_KEY);
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:5,代码来源:DropboxClient.java

示例9: onClickSync

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@OnClick(R.id.auth)
public void onClickSync() {
    Auth.startOAuth2Authentication(getApplicationContext(), getString(R.string.APP_KEY));
}
 
开发者ID:AbduazizKayumov,项目名称:Flashcard-Maker-Android,代码行数:5,代码来源:DropboxActivity.java

示例10: startAuth

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public void startAuth() {
    startedAuth = true;
    Auth.startOAuth2Authentication(context, APP_KEY);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:5,代码来源:Dropbox.java

示例11: login

import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@Override
public void login(Context context, OnSyncDataListener<Boolean> callback) {
    Auth.startOAuth2Authentication(context, Constants.DROPBOX_APPLICATION_KEY);
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:5,代码来源:DropboxManager.java


注:本文中的com.dropbox.core.android.Auth.startOAuth2Authentication方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。