android - 如何使用生成的保管箱访问令牌将我的保管箱文件连接到我在 android studio 中的保管箱控制台应用程序
问题描述
请在如何将我的个人保管箱文件连接到我创建的保管箱应用程序方面需要帮助。我想用我在 android studio 中为我的最后一年项目做的试用应用程序来尝试它。我浏览的所有网站都显示您应该使用生成按钮,但没有显示生成令牌后要做什么。请任何帮助将不胜感激。谢谢你。
解决方案
欢迎来到 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();
}}
推荐阅读
- wordpress - 使用 Elementor 构建的页面失去了样式
- java - 错误 500:访问 /grid/register/ 时出现问题 - 无法向 Selenium hub 注册 Appium 节点
- c++ - 如何最好地为 Visual Studio 2017 构建的 CMake C++ 项目设置输出目录?
- wordpress - How can I make this into an IF OR function?
- python - 如何修复:Django 表单:{{ form }} 在 html 页面中不显示任何结果
- html - 我们如何使放置在链接标签内的 div 不被导航
- javascript - AngularJS - 从服务调用控制器变量的多重继承
- json - 如何在带有标记的颤动中使用 json_serializable 以在 GoogleMap 中使用它们?
- tcp - boost beast websocket服务器读取错误代码文件结束和操作取消
- python-3.x - 无法从图像中提取数字