本文整理汇总了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();
}
}
示例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));
}
}
示例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);
}
}
示例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());
}
}
示例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;
}
}
示例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;
}
示例7: tryConnect
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public boolean tryConnect(Activity activity)
{
if (!mLoggedIn)
Auth.startOAuth2Authentication(activity, appInfo.getKey());
return mLoggedIn;
}
示例8: beginAuthentication
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public void beginAuthentication(Activity activity) {
tryLinking = true;
Auth.startOAuth2Authentication(activity, BuildConfig.DROPBOX_APP_KEY);
}
示例9: onClickSync
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@OnClick(R.id.auth)
public void onClickSync() {
Auth.startOAuth2Authentication(getApplicationContext(), getString(R.string.APP_KEY));
}
示例10: startAuth
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public void startAuth() {
startedAuth = true;
Auth.startOAuth2Authentication(context, APP_KEY);
}
示例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);
}