简体   繁体   English

使用哪种Android意图在Dropbox应用中获取“保存到设备”行为?

[英]Which Android intent to use to get the 'Save to device' behaviour in dropbox app?

Currently I am able to implement store and retrieve file from Google Drive without issue but I want to add an additional functionality which is to save the file directly to local storage. 目前,我可以实现从Google云端硬盘的存储和检索文件,而不会出现问题,但是我想添加其他功能,可以将文件直接保存到本地存储中。

In dropbox app, if you try to export a file and in the chooser select 'Save to device', it will show something like below: 在Dropbox应用中,如果您尝试导出文件,然后在选择器中选择“保存到设备”,则它将显示如下内容:

在此处输入图片说明

At first I thought they created the activity themselves but it looks very similar to the ACTION_GET_CONTENT intent that I am using.. My code is just something like: 起初我以为他们自己创建了活动,但它看起来与我正在使用的ACTION_GET_CONTENT意图非常相似。我的代码如下所示:

 Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
 intent.setType("application/*");
 startActivityForResult(intent, 0);

which show something like below: 显示如下:

在此处输入图片说明

That makes me think that Dropbox app must be using an Android intent to save file to local storage like ACTION_ADD_CONTENT or something.. Or am I wrong? 这使我认为Dropbox应用必须使用Android意图将文件保存到ACTION_ADD_CONTENT之类的本地存储中。还是我错了?

Thanks. 谢谢。

Kuffs has it right — you are seeing the UI for the Storage Access Framework. Kuffs正确无误-您正在看到Storage Access Framework的UI。 Specifically, for a "save as" sort of feature, use ACTION_CREATE_DOCUMENT . 具体来说,对于“另存为”某种功能,请使用ACTION_CREATE_DOCUMENT You will get back a content: Uri for the location that the user chose, and you can use a ContentResolver and openOutputStream() to write your data to that location. 您将获得一个content:用户选择的位置的Uri ,然后可以使用ContentResolveropenOutputStream()将数据写入该位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM