chol0p 0 Posted May 22, 2023 Hi all. I hope very much for your help. Is it possible to simply open a folder from application through a standard file manager? I save my images (photos from the camera) in the DCIM/MyFolder and I would like to add the ability for the user to open this folder from my application. So that when a button is pressed, he has a choice of applications (available file managers) through which he can open it. I will be grateful for help. Sorry, I'm using a translator. Thank you Share this post Link to post
Mustafa ֍zgun 7 Posted May 24, 2023 Hi apps targeting Android 10 and higher are given scoped access into external storage, or scoped storage. Android 11 introduces changes and restrictions to enhance user privacy, including the following: Scoped storage enforcement: Access into external storage directories is limited to an app-specific directory and specific types of media that the app has created. Open files using the Storage Access Framework The SAF includes the following: Document provider: a content provider that lets a storage service, such as Google Drive, reveal the files it manages. A document provider is implemented as a subclass of the DocumentsProvider class. The document-provider schema is based on a traditional file hierarchy, though how your document provider physically stores data is up to you. The Android platform includes several built-in document providers, such as Downloads, Images, and Videos. Client app: a custom app that invokes the ACTION_CREATE_DOCUMENT, ACTION_OPEN_DOCUMENT, and ACTION_OPEN_DOCUMENT_TREE intent actions and receives the files returned by document providers. Picker: a system UI that lets users access documents from all document providers that satisfy the client app's search criteria. https://developer.android.com/static/images/providers/storage_picker.svg Access documents and other files from shared storage Sample project Delphi - Android Scoped Storage : Storage Access Framework SAF API 1 Share this post Link to post
Minox 7 Posted May 25, 2023 If you have the rights to access the "DCIM/MyFolder" folder, you could build a simple browser (via "System.IOUtils.TDirectory.GetFiles") yourself and display the files contained in a list. Or launch an "Intent" with "ACTION_GET_CONTENT", to open the system app 1 Share this post Link to post
chol0p 0 Posted May 26, 2023 On 5/25/2023 at 1:12 PM, Minox said: If you have the rights to access the "DCIM/MyFolder" folder, you could build a simple browser (via "System.IOUtils.TDirectory.GetFiles") yourself and display the files contained in a list. Or launch an "Intent" with "ACTION_GET_CONTENT", to open the system app Could you show an example how to implement this using "ACTION_GET_CONTENT"? I already tried this with "Intent" but I keep getting the error " exposed beyond app through intent.getdata() " Share this post Link to post
Dave Nottage 557 Posted May 26, 2023 5 minutes ago, chol0p said: I already tried this with "Intent" but I keep getting the error " exposed beyond app through intent.getdata() " Please show your code Share this post Link to post
Minox 7 Posted May 27, 2023 I use this: uses Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers, System.Messaging, Androidapi.JNI.Net, Androidapi.JNI.App, PROCEDURE TForm1.GetFileBrowser; VAR Intent : JIntent; ReqCode : Integer; BEGIN ReqCode := 1000; Intent := TJIntent.Create; Intent.setType(StringToJString('*/*')); Intent.setAction(TJIntent.JavaClass.ACTION_GET_CONTENT); Intent.putExtra(TJIntent.JavaClass.EXTRA_ALLOW_MULTIPLE,true); TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification, procedure(const Sender : TObject; const aMessage : TMessage) VAR msgRES : TMessageResultNotification; begin msgRES:= TMessageResultNotification(aMessage); If msgRES.RequestCode=ReqCode Then if (msgRES.ResultCode=TJActivity.JavaClass.RESULT_OK) Then Begin URIfileTrn := msgRES.Value.getData(); //URI sing file selez If URIfileTrn=Nil Then //multiselez ClipDataF := msgRES.Value.getClipData; End; end); TAndroidHelper.Activity.startActivityForResult(Intent, ReqCode); END; and then via thread process the URI 3 Share this post Link to post
chol0p 0 Posted May 27, 2023 1 hour ago, Minox said: I use this: Thanks, but I just need to open the folder, without selecting the folder. Is it possible? Share this post Link to post
Minox 7 Posted May 27, 2023 (edited) If your intention is to open the explorer automatically in a specific location, I don't think it's possible to do it with the system one. Third-party ones do it instead, but I've never faced the problem. This session could be a good start to understand if there is a possibility to do it. Edited May 27, 2023 by Minox 1 Share this post Link to post
Grupo Datasoft 0 Posted June 13 On 5/27/2023 at 5:01 AM, Minox said: I use this: uses Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers, System.Messaging, Androidapi.JNI.Net, Androidapi.JNI.App, PROCEDURE TForm1.GetFileBrowser; VAR Intent : JIntent; ReqCode : Integer; BEGIN ReqCode := 1000; Intent := TJIntent.Create; Intent.setType(StringToJString('*/*')); Intent.setAction(TJIntent.JavaClass.ACTION_GET_CONTENT); Intent.putExtra(TJIntent.JavaClass.EXTRA_ALLOW_MULTIPLE,true); TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification, procedure(const Sender : TObject; const aMessage : TMessage) VAR msgRES : TMessageResultNotification; begin msgRES:= TMessageResultNotification(aMessage); If msgRES.RequestCode=ReqCode Then if (msgRES.ResultCode=TJActivity.JavaClass.RESULT_OK) Then Begin URIfileTrn := msgRES.Value.getData(); //URI sing file selez If URIfileTrn=Nil Then //multiselez ClipDataF := msgRES.Value.getClipData; End; end); TAndroidHelper.Activity.startActivityForResult(Intent, ReqCode); END; and then via thread process the URI How get the selected file path an filename on this function? I need select a video file an load on my form. Tks for you help Share this post Link to post
Minox 7 Posted June 14 (edited) Try var LCursor : JCursor := TAndroidHelper.Context.getContentResolver().query(URIfileTrn,nil,nil,nil,nil); If LCursor=Nil Then Exit; LCursor.moveToFirst; var colIndex : Integer := LCursor.getColumnIndexOrThrow(TJOpenableColumns.JavaClass.DISPLAY_NAME); If colIndex<>-1 Then Result := JStringToString(LCursor.getString(colIndex)); Except Result := ''; End; with the latest OS, with the path you get you can't do anything with it, personally I download the file in the personal folder and use it Edited June 14 by Minox Share this post Link to post