標題: dropbox get list of file intent [打印本頁] 作者: soul810707 時間: 2013-7-19 16:46 標題: dropbox get list of file intent 我在dropbox 官方的sdk範例上 利用intent 來做出一個檔案清單
加上 (****那是我加的intent)
public void onClick(View v) {
AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE);
if (mDBApi == null) {
mDBApi = new DropboxAPI<AndroidAuthSession>(session);
}
mDBApi.getSession().startAuthentication(Main.this);
***** Intent intent = new Intent();
intent.setClass(Main.this, list.class);
startActivity(intent);
Main.this.finish();********
}
但當我按下連結後 就會當掉 無法進入到連結網頁驗證的的部分 也無法到另一個xml檔
但想先利用intent 登入完後 到list intent 但就失敗了 作者: ploglin 時間: 2013-7-22 17:08
那你把 Locat 中的 Error 放上來讓大家幫你看看,這樣比較快作者: soul810707 時間: 2013-7-22 21:39
謝謝回復:)
因為logcat 的錯誤太多了 我貼不完 以下是dropbox 官網提供的api example 他有提供三個檔案 一個上傳 一個下載 一個主認證 認證的地方在下面
我試過很多地方 以下有笑臉的地方是我試過 但都無法成功的跳的另一個intent 不知道我
Intent intent = new Intent();
intent.setClass(DBRoulette.this, list.class);
startActivity(intent);
DBRoulette.this.finish(); 該擺在哪阿~~
然後有個小疑問 為何不能在紅字那邊 改成 list.class 直接跳過去?
[code]
public class DBRoulette extends Activity {
private static final String TAG = "DBRoulette";
final static private String APP_KEY = "bsobztcrcac2a36";
final static private String APP_SECRET = "njp7yxg8f1aypci";
// If you'd like to change the access type to the full Dropbox instead of
// an app folder, change this value.
final static private AccessType ACCESS_TYPE = AccessType.APP_FOLDER;
// You don't need to change these, leave them alone.
final static private String ACCOUNT_PREFS_NAME = "prefs";
final static private String ACCESS_KEY_NAME = "ACCESS_KEY";
final static private String ACCESS_SECRET_NAME = "ACCESS_SECRET";
if (savedInstanceState != null) {
mCameraFileName = savedInstanceState.getString("mCameraFileName");
}
// We create a new AuthSession so that we can use the Dropbox API.
AndroidAuthSession session = buildSession();
mApi = new DropboxAPI<AndroidAuthSession>(session);
mSubmit.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// This logs you out if you're logged in, or vice versa
if (mLoggedIn) {
logOut();
} else {
// Start the remote authentication
mApi.getSession().startAuthentication(DBRoulette.this);
}
}
});
// mDisplay = (LinearLayout)findViewById(R.id.logged_in_display);
// Display the proper UI state if logged in or not
setLoggedIn(mApi.getSession().isLinked());
// The next part must be inserted in the onResume() method of the
// activity from which session.startAuthentication() was called, so
// that Dropbox authentication completes properly.
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);
setLoggedIn(true);
// This is what gets called on finishing a media piece to import
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == NEW_PICTURE) {
// return from file upload
if (resultCode == Activity.RESULT_OK) {
Uri uri = null;
if (data != null) {
uri = data.getData();
}
if (uri == null && mCameraFileName != null) {
uri = Uri.fromFile(new File(mCameraFileName));
}
File file = new File(mCameraFileName);
if (uri != null) {
UploadPicture upload = new UploadPicture(this, mApi, PHOTO_DIR, file);
upload.execute();
}
} else {
Log.w(TAG, "Unknown Activity Result from mediaImport: "
+ resultCode);
}
}
}
private void logOut() {
// Remove credentials from the session
mApi.getSession().unlink();
// Clear our stored keys
clearKeys();
// Change UI state to display logged out version
setLoggedIn(false);
}
/**
* Convenience function to change UI state based on being logged in
private void setLoggedIn(boolean loggedIn) {
mLoggedIn = loggedIn;
if (loggedIn) {
mSubmit.setText("Unlink from Dropbox");
mDisplay.setVisibility(View.VISIBLE);
} /*else {
mSubmit.setText("Link with Dropbox");
mDisplay.setVisibility(View.GONE);
mImage.setImageDrawable(null);
}*/
}