android-fileprovider

FileProvider.getUriForFile returns null

↘锁芯ラ 提交于 2019-12-02 06:18:30
I'm trying to take a photo in my device's camera, when I call the method that handles the image capture the app crashes because of a nullpointer exception. I don't know what information is missing with my FileProvider as the stacktrace points the nullpointer into my FileProvider.getUriForFile statement. Here's my code HomeActivity public void takePhoto(View view){ //camera stuff Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); //folder stuff File imagesFolder = new File(Environment

Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser

烈酒焚心 提交于 2019-12-02 04:52:44
问题 I am getting this error.I am new to android studio and i need to create this plugin for unity to install an apk at runtime Error - Attempt to invoke virtual method 'android.content.Context Android.content.Context.getApplicationContext()' on a null object reference Plugin Class - package com.example.unitypluginappinstall; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.support.v4.content.FileProvider; import

How do I open an internally created pdf in Xamarin.Android via a FileProvider in the default system pdf app?

若如初见. 提交于 2019-12-02 04:22:06
问题 I created a .pdf file in the private local directory I got via (I try to work with the minimum of permissions): string targetBaseDir = Environment.GetFolderPath( Environment.SpecialFolder.Personal, Environment.SpecialFolderOption.Create ); The official Android documentation suggests that file should be shared via a FileProvider. I also tried to get some code to start an intent, and I'm currently at: var fileUri = Android.Net.Uri.Parse(filePath); var intent = new Intent(); intent.SetFlags

Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser

十年热恋 提交于 2019-12-02 02:29:35
I am getting this error.I am new to android studio and i need to create this plugin for unity to install an apk at runtime Error - Attempt to invoke virtual method 'android.content.Context Android.content.Context.getApplicationContext()' on a null object reference Plugin Class - package com.example.unitypluginappinstall; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.support.v4.content.FileProvider; import java.io.File; public class PluginClass extends Activity { static String errMessage; public static String

How do I open an internally created pdf in Xamarin.Android via a FileProvider in the default system pdf app?

≯℡__Kan透↙ 提交于 2019-12-02 01:22:58
I created a .pdf file in the private local directory I got via (I try to work with the minimum of permissions): string targetBaseDir = Environment.GetFolderPath( Environment.SpecialFolder.Personal, Environment.SpecialFolderOption.Create ); The official Android documentation suggests that file should be shared via a FileProvider . I also tried to get some code to start an intent, and I'm currently at: var fileUri = Android.Net.Uri.Parse(filePath); var intent = new Intent(); intent.SetFlags(ActivityFlags.ClearTop); intent.SetFlags(ActivityFlags.NewTask); intent.SetAction(Intent.ActionView);

How to open an APK file for all Android versions

霸气de小男生 提交于 2019-12-01 18:08:08
Background So far, there was an easy way to install an APK file, using this intent: final Intent intent=new Intent(Intent.ACTION_VIEW) .setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); But, if your app targets Android API 24 and above (Nougat - 7.0) , and you run this code on it or newer, you will get an exception, as shown here , for example: android.os.FileUriExposedException: file:///storage/emulated/0/sample.apk exposed beyond app through Intent.getData() The problem So I did what I was told: use the support library's FileProvider class, as such: final

android.support.v4.content.FileProvider class not found in android Kitkat

跟風遠走 提交于 2019-12-01 15:33:01
I am using FileProvider in my app. As usual I declared <Provider> tag in AndroidManifest.xml file as below. <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.jk.android.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider> When I run it on android device which has lollipop version it works fine. when I try it on kitkat version it shows following errors: FATAL EXCEPTION: main Process: com.jk.android.perfectphotoeditor2018,

Android getUriForFile IllegalArgumentException

送分小仙女□ 提交于 2019-12-01 10:44:59
问题 My code for sending a file with an Intent doesn't work with all file sources and I could not find the solution yet: My app is registered for opening files, so when I select a file in ES File Explorer the intent looks like this: intent->mData->uriString=/storage/emulated/0/backups/apps/NextGenEndPoint_1.0.apk when selecting the same file in Asus File Manager I get following intent: intent->mData->uriString=/file/sdcard/backups/apps/NextGenEndPoint_1.0.apk This is my code: // With this path it

FileProvider.getUriForFile returns NullPointerException

笑着哭i 提交于 2019-12-01 00:53:38
问题 I'm trying to write my first android app, which will involve taking a picture and doing stuff with it. I've put together some code after looking at several tutorials online but am getting the following NullPointerException whenever the button is clicked: 10-03 14:48:00.284 26310-26310/org.broadinstitute.jsnap E/MainActivity: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm

Xamarin Forms File Provider not set

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 18:09:23
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}); if (photo != null) return ImageSource.FromStream(() => { return photo.GetStream(); }); else return null