因此,系统会提示用户输入文件名,并将文件保存到外部存储中。完成后,我调用另一种方法保存到 Dropbox。这会创建另一个对话框;一个简单的“是/否”,用户可以接受或拒绝保存到 Dropbox。
当文件保存到外部存储时,Dropbox 对话框会显示,但整个屏幕是灰色的,就像它失去了焦点一样。点击屏幕使其恢复正常,所有功能都可以,但很烦人。下面的代码和屏幕截图。
private void saveToSD(){
//Build dialog etc
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Save file to phone and then...
saveToDropbox();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
而且saveToDropbox();
方法...
private void saveToDropbox(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
if (mDbxAcctMgr.hasLinkedAccount()){
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Upload to Dropbox")
.setMessage("Do you want to upload the file to Dropbox?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "This is when we would save to Dbx", Toast.LENGTH_LONG).show();
}
})
.setNegativeButton("No", null)
.show();
builder.show();
}else{
Toast.makeText(getApplicationContext(), "Not linked to Dropbox", Toast.LENGTH_LONG).show();
}
}