[Bug]: Passing Uri into android.intent.extra.STREAM cause an exception
Platform
Android 11
Plugin
android_intent_plus
Version
3.1.1
Flutter SDK
3.0.1
Steps to reproduce
According to Instagram documentation, the following code snippet should be able to pass Uri of image to Instagram Feed Post intent. But it caused an exception: Argument Error.
final intent = AndroidIntent(
action: 'action_send',
type: 'image/*',
arguments: {'android.intent.extra.STREAM': file.uri}, // <- file is an instance of File
);
intent.launchChooser('Share to');
Logs
Exception has occurred.
ArgumentError (Invalid argument: Instance of '_Uri')
Flutter Doctor
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.19044.1706], locale en-US)
• Flutter version 3.0.1 at D:\Tools\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fb57da5f94 (2 weeks ago), 2022-05-19 15:50:29 -0700
• Engine revision caaafc5604
• Dart version 2.17.1
• DevTools version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at C:\Users\<User>\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] VS Code (version 1.67.2)
• VS Code at C:\Users\<User>\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.42.0
[√] Connected device (4 available)
• SHARK PRS H0 (mobile) • e56a9b65 • android-arm64 • Android 11 (API 30)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1706]
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.63
• Edge (web) • edge • web-javascript • Microsoft Edge 102.0.1245.30
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
Can you post the full error log?
My understanding is that you are mixing Dart code and Java code. You are sending a Dart URI object to the Java native side, and the Java native side doesn't support it.
I'd suggest you to look into either submitting a PR that supports that type of argument or looking into implementing that natively.
Take a look at: https://github.com/fluttercommunity/plus_plugins/blob/8252a3ff7a1f2a99d04c6f05ad0cdbba6cd67f11/packages/android_intent_plus/android/src/main/java/dev/fluttercommunity/plus/androidintent/MethodCallHandlerImpl.java#L133
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days