首页 > 解决方案 > 如何使用生成的保管箱访问令牌将我的保管箱文件连接到我在 android studio 中的保管箱控制台应用程序

问题描述

请在如何将我的个人保管箱文件连接到我创建的保管箱应用程序方面需要帮助。我想用我在 android studio 中为我的最后一年项目做的试用应用程序来尝试它。我浏览的所有网站都显示您应该使用生成按钮,但没有显示生成令牌后要做什么。请任何帮助将不胜感激。谢谢你。

标签: android

解决方案


欢迎来到 stackoverflow :) 实际上Dropbox上有一个完整的教程站点,您可以在其中找到查​​看和上传文件和目录的示例。是您需要的android示例。

来自 Dropbox 的示例:

public class UserActivity extends DropboxActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_user);

    Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);

    Button loginButton = (Button)findViewById(R.id.login_button);

    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Auth.startOAuth2Authentication(UserActivity.this, getString(R.string.app_key));
        }
    });

    Button filesButton = (Button)findViewById(R.id.files_button);
    filesButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(FilesActivity.getIntent(UserActivity.this, ""));
        }
    });

    Button openWithButton = (Button)findViewById(R.id.open_with);
    openWithButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent openWithIntent = new Intent(UserActivity.this, OpenWithActivity.class);
            startActivity(openWithIntent);
        }
    });
}

@Override
protected void onResume() {
    super.onResume();

    if (hasToken()) {
        findViewById(R.id.login_button).setVisibility(View.GONE);
        findViewById(R.id.email_text).setVisibility(View.VISIBLE);
        findViewById(R.id.name_text).setVisibility(View.VISIBLE);
        findViewById(R.id.type_text).setVisibility(View.VISIBLE);
        findViewById(R.id.files_button).setEnabled(true);
        findViewById(R.id.open_with).setEnabled(true);
    } else {
        findViewById(R.id.login_button).setVisibility(View.VISIBLE);
        findViewById(R.id.email_text).setVisibility(View.GONE);
        findViewById(R.id.name_text).setVisibility(View.GONE);
        findViewById(R.id.type_text).setVisibility(View.GONE);
        findViewById(R.id.files_button).setEnabled(false);
        findViewById(R.id.open_with).setEnabled(false);
    }
}

@Override
protected void loadData() {
    new GetCurrentAccountTask(DropboxClientFactory.getClient(), new GetCurrentAccountTask.Callback() {
        @Override
        public void onComplete(FullAccount result) {
            ((TextView) findViewById(R.id.email_text)).setText(result.getEmail());
            ((TextView) findViewById(R.id.name_text)).setText(result.getName().getDisplayName());
            ((TextView) findViewById(R.id.type_text)).setText(result.getAccountType().name());
        }

        @Override
        public void onError(Exception e) {
            Log.e(getClass().getName(), "Failed to get account details.", e);
        }
    }).execute();
}}

推荐阅读