0
我有我的应用程序应该上传文件到Dropbox的多个地方。当我尝试上传文件时,应用程序正在退回浏览器。如果我全局使用DropboxApi对象,则表示DropboxUnlinkedException。 我张贴我的代码Dropbox落在浏览器上,每次我上传文件
Dropbox.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// We create a new AuthSession so that we can use the Dropbox API.
AndroidAuthSession session = buildSession();
AJ_Constant.mApi = new DropboxAPI<AndroidAuthSession>(session);
// Basic Android widgets
// setContentView(R.layout.main);
if (mLoggedIn) {
logOut();
} else {
// Start the remote authentication
AJ_Constant.mApi.getSession().startAuthentication(DropBox.this);
}
}
@Override
protected void onResume() {
super.onResume();
if (session.authenticationSuccessful()) {
try {
// Mandatory call to complete the auth
session.finishAuthentication();
// Store it locally in our app for later use
TokenPair tokens = session.getAccessTokenPair();
storeKeys(tokens.key, tokens.secret);
} catch (IllegalStateException e) {
showToast("Couldn't authenticate with Dropbox:"
+ e.getLocalizedMessage());
Log.i(TAG, "Error authenticating", e);
}
}
}
上传文件的代码是: (此代码是在另一个文件_someX.java)
com.dropbox.client2.DropboxAPI.Entry response = AJ_Constant.mApi.putFile(
AJ_Constant.ReportfileName, inputStream, file.length(),
null, null);
我应该重新建立会话或每次完成认证过程? 请给我建议任何解决方案提前
我看到授权后存储访问令牌对的代码,但是在下次运行应用程序时,我没有看到您使用该令牌对的位置。你能分享你的部分代码吗? – smarx 2014-08-30 15:40:36
@smarx:我没有在任何地方使用它。我应该如何使用该令牌对创建会话?你能告诉我吗? – Ravitheja 2014-09-01 08:21:28