You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/03/22 04:39:33 UTC
[GitHub] [cordova] gabriele-sacchi opened a new issue #84: Missing Intent
type and category prevent file upload
gabriele-sacchi opened a new issue #84: Missing Intent type and category prevent file upload
URL: https://github.com/apache/cordova/issues/84
# Bug Report
Files upload not working on Android when the Cordova App uses [ng-file-upload](https://github.com/danialfarid/ng-file-upload/issues/2111).
( works on iOS 👇👇 )
![image](https://user-images.githubusercontent.com/48427520/54739187-9c85d800-4b8d-11e9-8750-76cd378ec145.png)
PLEASE NOTE THAT THIS IS A DUPLICATE OF https://github.com/apache/cordova-android/issues/695. I RAISED IT HERE AS PER INSTRUCTIONS RECEIVED ON THIS PAGE:
https://cordova.apache.org/announcements/2019/02/16/cordova-android-release-8.0.0.html
Feel free to close either one. Thanks :)
## Problem
Using [ng-file-upload](https://github.com/danialfarid/ng-file-upload) it is not possible to upload images or document on Android when the App is built using Cordova.
The 2 lines fix suggested below will resolve the Issue opened [here](https://github.com/danialfarid/ng-file-upload/issues/2111) on the ng-file-upload repository and the [related Stackoverflow](https://stackoverflow.com/questions/55261705/file-upload-not-working-for-android-in-cordova-project).
This is the line after which the following 2 lines of code need to be added:
https://github.com/apache/cordova-android/blob/2163c8ae0536bfde9029cfc981b945f4af93e09f/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java#L253
Bug fix - **2 lines of code**:
```
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
Intent intent = fileChooserParams.createIntent();
// FIX HERE (same as the above handler) vvvvvvvvvvvvvv @@
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
// FIX HERE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@
```
### What is expected to happen?
The user should be prompted to choose which app to use to pick a file to upload
### What does actually happen?
On click no file picker is shown
## Information
These logs get generated when the upload button that should open the file picker is clicked:
"No activity found to handle file chooser intent.: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT cat= [android.intent.category.OPENABLE] typ=.jpg,.png,.tiff,.jpeg,.tif,.pdf }"
### Command or Code
Unfortunately I cannot share the code.
### Environment, Platform, Device
Android app built with Cordova.
Same result using the default WebView and the WebView provided by cordova-plugin-ionic-webview.
### Version information
Same result on cordova-android 7 and 8.
## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org