Issue
I am using the android_intent
package for sending the ACTION_EDIT
intent in order to make an image editable but I keep getting an error.
I have looked up the issue online and saw that I need to create a class that extends FileProvider
if my SDK
version is higher than or equal to 24
in order to solve the problem but I couldn't figure out how to do that in flutter.
The function I am using in order to pick the image and send it to the phone editor:
Future getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.camera);
if (Platform.isAndroid) {
var intent =
AndroidIntent(action: 'action_edit', data: image.uri.toString());
await intent.launch();
}
setState(() {
_image = image;
});
}
The error I am getting:
PlatformException (PlatformException(error, file:///storage/emulated/0/Android/data/com.example.app/files/Pictures/eebbf5f6-0a08-462b-9564-63c1a226e6a24636306815702344465.jpg exposed beyond app through Intent.getData(), null))
I/io.flutter.plugins.androidintent.AndroidIntentPlugin(30575): Sending intent Intent { act=action_edit dat=file:///storage/emulated/0/Android/data/com.example.app/files/Pictures/eebbf5f6-0a08-462b-9564-63c1a226e6a24636306815702344465.jpg }
E/MethodChannel#plugins.flutter.io/android_intent(30575): Failed to handle method call
E/MethodChannel#plugins.flutter.io/android_intent(30575): android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.example.app/files/Pictures/eebbf5f6-0a08-462b-9564-63c1a226e6a24636306815702344465.jpg exposed beyond app through Intent.getData()
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.os.StrictMode.onFileUriExposed(StrictMode.java:1978)
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.net.Uri.checkFileUriExposed(Uri.java:2371)
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.content.Intent.prepareToLeaveProcess(Intent.java:10936)
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.content.Intent.prepareToLeaveProcess(Intent.java:10887)
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1667)
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.app.Activity.startActivityForResult(Activity.java:4688)
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.app.Activity.startActivityForResult(Activity.java:4646)
E/MethodChannel#plugins.flutter.io/android_intent(30575): at android.app.Activity.startActivity(Activity.java:5007)
Do you know how this problem can be solved?
Solution
I sort of solved the problem, I changed the package of intents from android_intent
to intent
and then I somehow got to see the available apps for ACTION_EDIT
which there are not on my emulator/phone.
Answered By - Alon Yeager
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.