plejazz.blogg.se

Android studio intent open folder on file explorer
Android studio intent open folder on file explorer










android studio intent open folder on file explorer

In order to get the result after user selecting file, we need to handle it by overriding onActivityResult.įilePickerFragment. The request code needs to be unique to distinguish it from other activity results. Then call startActivityForResult with the Intent as the first parameter and a request code as the second paramter.

android studio intent open folder on file explorer

We need to add setOnClickListner inside which a new ACTION_GET_CONTENT Intent is created. In the activity or fragment, we need to handle when the button is clicked and when a file has been chosen by user. To keep this tutorial simple, there is only a Button that will trigger to show the file picker when it's clicked and a TextView for showing the path of selected file. You can also use this action for opening multiple files: .myfiles.PICK_DATA_MULTIPLEĪnyway here is my solution which works on samsung and other devices: public void openFile(String minmeType) catch ( you need to show file picker in your Android application to allow users choosing file in their local storage? This tutorial shows you how to show a simple file picker and get the File object of selected file. Intent.addCategory(Intent.CATEGORY_DEFAULT) Intent intent = new Intent(".myfiles.PICK_DATA") CATEGORY_DEFAULT) and mime-type should be passed as extra. Samsung file explorer needs not only custom action ( .myfiles.PICK_DATA),īut also category part (Intent. Navigate to the app > res > layout > activitymain.xml and add the. Step 2: Working with the activitymain.xml file.

android studio intent open folder on file explorer android studio intent open folder on file explorer

My customers are Galaxy SII owners only and I don't want to force them to install Astro file manager given that they already have a basic but sufficient file manager.Īny idea of how I could achieve this ? I am pretty sure that I already saw the default file manager appear in such a menu to pick a file, but I can't remember in which app. To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. If I install Astro file manager it will respond to that intent, too. I would also like the camera app to show in the list, so that the user can shoot a picture and send it through my app. There is a file explorer on this device and I would like it to appear in the list. StartActivityForResult(i, CHOOSE_FILE_REQUESTCODE) īut it only shows "Gallery" and "Music player" on my Galaxy S2. These are handled by Activities in android studio. These intents refers to any class and available in package. Intent i = Intent.createChooser(intent, "File") Using Explicit Intent you can call another Activity and pass some data in intent. Intent.addCategory(Intent.CATEGORY_OPENABLE) I would like to start an intentchooser for apps which can return any kind of fileĬurrently I use (which I copied from the Android email source code for file attachment) Intent intent = new Intent(Intent.ACTION_GET_CONTENT)












Android studio intent open folder on file explorer