android-fileprovider

Android file chooser with specific file extensions

本秂侑毒 提交于 2019-11-28 11:28:51
I need to show only 'pdf' files in my application when I run default File chooser I'm not able to filter file extensions. final Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT); getContentIntent.setType("application/pdf"); getContentIntent.addCategory(Intent.CATEGORY_OPENABLE); Intent intent = Intent.createChooser(getContentIntent, "Select a file"); startActivityForResult(intent, REQUEST_PDF_GET); File chooser shows any kinds of files. I would like to show only pdf files. How can i filter files showed by File chooser. It's an unknown to you what user-installed file browser apps

Android taking picture with FileProvider

一笑奈何 提交于 2019-11-28 07:59:21
问题 I'm taking a picture on Android Nougat with FileProvider, that's my code <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.mypackage.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider> file_paths.xml: <paths> <files-path name="img" path="images/" /> </paths> Java: String fileName = "cameraOutput" + System

FileProvider Not Working with Camera

a 夏天 提交于 2019-11-28 05:14:07
I'm trying to make Camera App to store the output to my internal storage. I also understand that third party apps are not able to access the Internal Storage of my application BUT we are able to do so by exposing the internal directory through FileProvider . I have followed the guide here: Camera Intent not saving photo https://developer.android.com/reference/android/support/v4/content/FileProvider.html I specify my AndroidManifest.xml in the following way: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.stackoverflow

Android: FileProvider IllegalArgumentException Failed to find configured root that contains /data/data/**/files/Videos/final.mp4

断了今生、忘了曾经 提交于 2019-11-27 15:28:49
问题 I am trying to use FileProvider to play a video from private path.Facing java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/XXXXX(Package)/files/Videos/final.mp4 Code: <paths> <files-path path="my_docs" name="Videos/" /> </paths> Java code: File imagePath = new File(getFilesDir(), "Videos"); File newFile = new File(imagePath, "final.mp4"); Log.d(TAG, "-------------newFile:"+newFile.exists());//True here //Exception in below line Uri contentUri =

SecurityException with grantUriPermission when sharing a file with FileProvider

拥有回忆 提交于 2019-11-27 14:03:08
I have two applications. I'm trying to share a file from application A to application B using a FileProvider. Application A calls the insert method on a ContentProvider in Application B to insert a record. The data inserted includes the Uri to the file I want to share from App A. The ContentProvider in App B would then try to read the shared file from App A. Since I'm not using an Intent to share the file, I'm calling Context.grantUriPermission in App A to allow the read (and at times write): mContext.grantUriPermission(MyPackageName, contentUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent

FileProvider throws exception on GetUriForFile

℡╲_俬逩灬. 提交于 2019-11-27 13:57:10
I followed the example code on the android developer reference on FileProviders but it won't work. I have setup the path files/exports/ in the file provider definition in my Manifest and the referenced files does exist at that path. In my Manifest: <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.company.app.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider> And in xml/file_paths.xml <?xml version="1.0" encoding="UTF-8"

Implementing a File Picker in Android and copying the selected file to another location

无人久伴 提交于 2019-11-27 13:46:35
问题 I'm trying to implement a File Picker in my Android project. What I've been able to do so far is : Intent chooseFile; Intent intent; chooseFile = new Intent(Intent.ACTION_GET_CONTENT); chooseFile.setType("*/*"); intent = Intent.createChooser(chooseFile, "Choose a file"); startActivityForResult(intent, PICKFILE_RESULT_CODE); And then in my onActivityResult() switch(requestCode){ case PICKFILE_RESULT_CODE: if(resultCode==-1){ Uri uri = data.getData(); String filePath = uri.getPath(); Toast

Android : FileProvider on custom external storage folder

浪尽此生 提交于 2019-11-27 13:04:14
问题 I'm trying to set up a fileprovider for sharing file. My files are saved in a folder "AppName" in the external storage (same level as Android, Movies and Pictures folders). Here is my file provider config : <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.mydomain.appname.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> <

How to get uri of captured photo?

為{幸葍}努か 提交于 2019-11-27 07:52:58
问题 What do I want to achieve? I want to get URI of the captured image and save it on Firebase. What did I try? First of all I needed to open the camera. Below how I did it: Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); if (cameraIntent.resolveActivity(getActivity().getPackageManager()) != null) startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE); After capturing the image, I needed to get the URI of the image. Below how I did it: if (resultCode ==

FileProvider Not Working with Camera

ぃ、小莉子 提交于 2019-11-27 05:31:26
问题 I'm trying to make Camera App to store the output to my internal storage. I also understand that third party apps are not able to access the Internal Storage of my application BUT we are able to do so by exposing the internal directory through FileProvider . I have followed the guide here: Camera Intent not saving photo https://developer.android.com/reference/android/support/v4/content/FileProvider.html I specify my AndroidManifest.xml in the following way: <?xml version="1.0" encoding="utf-8