Select File from file manager via Intent

后端 未结 2 1628
攒了一身酷
攒了一身酷 2021-02-20 08:31

What I wanna do:

I wanna get the path as a String of a file, which I choose via an Android File Manager.

What I have:



        
相关标签:
2条回答
  • 2021-02-20 08:42

    So for my Samsung device this worked:

    Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
    intent.putExtra("CONTENT_TYPE", "*/*");
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    startActivityForResult(intent, FILE_SELECT_CODE);
    
    0 讨论(0)
  • You can use this:

    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("*/*"); 
    startActivityForResult(intent, REQUEST_CODE);
    

    For samsung devices to open file manager use this:

    Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
    intent.putExtra("CONTENT_TYPE", "*/*");
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    

    For more reference checkout http://developer.android.com/guide/topics/providers/document-provider.html

    0 讨论(0)
提交回复
热议问题