简体   繁体   中英

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.

In dropbox app, if you try to export a file and in the chooser select 'Save to device', it will show something like below:

在此处输入图片说明

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:

 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?

Thanks.

Kuffs has it right — you are seeing the UI for the Storage Access Framework. Specifically, for a "save as" sort of feature, use 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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