android-fileprovider

Content uri crashes camera on Android KitKat

旧街凉风 提交于 2019-11-30 16:06:27
I run into problem while using content uri and FileProvider on Android API 19 (Kitkat). Here's code that I use to open camera on device and record a video: File file = new File(pathname); Uri fileUri = FileProvider.getUriForFile(this, AUTHORITY_STRING, file); Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); startActivityForResult(intent, requestCode); I've tested this code on API's 23-24 and it works just fine, but on API 19 camera closes with RESULT_CANCELED after I starting to take video in camera app. The same thing happening

FileProvider and secondary external storage

半城伤御伤魂 提交于 2019-11-30 14:15:49
How can I serve files from the SECONDARY external storage using the FileProvider ? The current implementation of the FileProvider handles only the first directory returned by ContextCompat.getExternalFilesDirs ... } else if (TAG_EXTERNAL_FILES.equals(tag)) { File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null); if (externalFilesDirs.length > 0) { target = externalFilesDirs[0]; } } ... It seems, that there is no way to define a <path> entry for the FileProvider , that matches the secondary external storage path... And the answer is... FileProvider does not support that.

Android : FileProvider on custom external storage folder

我的梦境 提交于 2019-11-30 05:11:35
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"/> </provider> and the file_paths.xml : <paths xmlns:android="http://schemas.android.com/apk/res/android">

Xamarin Forms File Provider not set

风流意气都作罢 提交于 2019-11-30 02:04:13
问题 I am currently going through the process of Learning Xamarin.Forms. I am currently attempting to implement Camera functions using the Plugin.Media.CrossMedia library. Implemented below: public async Task<ImageSource> StartCamera() { await CrossMedia.Current.Initialize(); if (Plugin.Media.CrossMedia.Current.IsTakePhotoSupported && CrossMedia.Current.IsCameraAvailable) { var photo = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions() { SaveToAlbum=false, SaveMetaData=false});

FileProvider and secondary external storage

落爺英雄遲暮 提交于 2019-11-29 19:28:13
问题 How can I serve files from the SECONDARY external storage using the FileProvider ? The current implementation of the FileProvider handles only the first directory returned by ContextCompat.getExternalFilesDirs ... } else if (TAG_EXTERNAL_FILES.equals(tag)) { File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null); if (externalFilesDirs.length > 0) { target = externalFilesDirs[0]; } } ... It seems, that there is no way to define a <path> entry for the FileProvider , that

Android taking picture with FileProvider

妖精的绣舞 提交于 2019-11-29 14:16:24
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.currentTimeMillis() + ".jpg"; File imagePath = new File(getContext().getFilesDir(), "images"); File file = new File

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

南楼画角 提交于 2019-11-29 00:55:55
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 = FileProvider.getUriForFile(this,"com.wow.fileprovider", newFile); Manifest.xml <provider android:name=

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

谁说我不能喝 提交于 2019-11-28 21:26:09
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.makeText(getActivity(), filePath, Toast.LENGTH_LONG).show(); } break; } This is opening a file picker, but

How to get uri of captured photo?

女生的网名这么多〃 提交于 2019-11-28 13:43:40
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 == Activity.RESULT_OK) { if (requestCode == CAMERA_REQUEST_CODE) { if (data != null) { if (data.getData() !=

Trying to open PDF file from assets folder using fileProvider but it gives FileNotFoundException: No such file or directory [duplicate]

牧云@^-^@ 提交于 2019-11-28 12:32:50
问题 This question already has answers here : Read a pdf file from assets folder (8 answers) Closed last year . I am trying to display "NEFT.pdf" file stored in the asset folder of my android app. The following code works absolutely fine till API 25 private void CopyReadAssets(String filename) { AssetManager assetManager = getAssets(); InputStream in = null; OutputStream out = null; File file = new File(getFilesDir(), filename); try { in = assetManager.open(filename); out = openFileOutput(file