Samsung My Files explorer:从指定文件夹中选择文件

时间:2023-01-17 08:39:59

I'm using the following code to open Samsung's My Files application to pick a file...

我正在使用以下代码打开三星的My Files应用程序来选择文件...

  public void openFileBrowser( ) {
        Intent intent = new Intent( "com.sec.android.app.myfiles.PICK_DATA" );
        try {
            startActivityForResult( intent, PICKFILE_RESULT_CODE );
        } catch ( ActivityNotFoundException e ) { 
            e.printStackTrace( );
            Log.log( Log.ERROR, TAG + "MyFiles is not installed !!" );
        }
    }   

this opens My Files application and lets user choose a file through it.
However, I wish to open a particular folder on device's external memory... and let user choose a file from there.... I tried achieving this by doing...

这将打开“我的文件”应用程序,并允许用户通过它选择文件。但是,我希望在设备的外部存储器上打开一个特定的文件夹...并让用户从那里选择一个文件....我尝试通过做...

 public void openFileBrowser( ) {
        Intent intent = new Intent( "com.sec.android.app.myfiles.PICK_DATA" );
        File root = new File( Environment.getExternalStorageDirectory( ).getPath( ) + "/MyFolder" );
        Uri uri = Uri.fromFile( root ); 
        intent.setData( uri );        
        try {
            startActivityForResult( intent, PICKFILE_RESULT_CODE );
        } catch ( ActivityNotFoundException e ) {
            e.printStackTrace( );
            Log.log( Log.ERROR, TAG + "MyFiles is not installed !!" );
        }
    }    

But I get an exception as :

但我得到一个例外:

 W/System.err(14682): android.content.ActivityNotFoundException: No Activity found to    handle Intent { act=com.sec.android.app.myfiles.PICK_DATA dat=file:///storage   /emulated/0/MyFolder }    

Can someone please help me with this?
Thank you!

有人可以帮我这个吗?谢谢!

1 个解决方案

#1


0  

You can set specify the startlocation in samsung Intent by specifying the FOLDERPATH like below.

您可以通过指定FOLDERPATH来设置在三星Intent中指定startlocation,如下所示。

intent.PutExtra("FOLDERPATH", path);   

#1


0  

You can set specify the startlocation in samsung Intent by specifying the FOLDERPATH like below.

您可以通过指定FOLDERPATH来设置在三星Intent中指定startlocation,如下所示。

intent.PutExtra("FOLDERPATH", path);