ionic-team / ionic-team/capacitor
feat: consistent file input behavior on android
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 1.3k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 10
Description
## Feature Request
### Description
When using `` on Android, allow the user to choose what app to use (e.g. Camera or Files), unless the behavior is restricted by `accept` or `capture` attributes.
Current behavior on Android with Capacitor seems to be:
- If [`capture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture) attribute is present, and `IMAGE_CAPTURE` action is defined in `AndroidManifest.xml` then open the camera,
- Otherwise open the file browser
This differs from the behavior in Chrome for Android or Capacitor on iOS, both of which let the user choose between multiple apps when the `capture` attribute isn't set.
### Platform(s)
- Android
### Preferred Solution
Show an [app chooser](https://developer.android.com/training/basics/intents/sending#AppChooser) an Android depending on the `accept` and `capture` properties:
- If [`capture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture) attribute is present, then directly open camera
- If [`accept`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept) attribute is used to only include types that aren't images, then directly open file browser
- Otherwise show an [app chooser](https://developer.android.com/training/basics/intents/sending#AppChooser), which should include at least Camera and File options

Also document that on Android it's necessary to add the following code to `AndroidManifest.xml` in order to show the camera from a file input:
```xml
```
### Alternatives
Document the differences in behavior between Android and web/iOS, as well as a suggested workaround (e,g, implementing a custom action sheet or popover with options for Camera and Files).
### Additional Context
- https://github.com/apache/cordova-android/issues/816
- https://github.com/ionic-team/capacitor/pull/809
Contributor guide
Assessment
This issue has not been assessed yet.