-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not open camera when I click input type="file" on Android devices #328
Comments
the same with me ? now ,I can open camera but I can't get the Image from camera. I think the inappbrowser can't get the message from cordova plugin result. |
Hi, we have the same problem. Use this url to test: https://mobilehtml5.org/ts/?id=23 android using browser : open camera (ok) ios using browser: open camera (ok) config.xml
@janpio update on this since it was open? |
help! I have the same issue. |
I solve change InAppBrowser plugin. I merged solution on https://stackoverflow.com/questions/51168600/webview-open-camera-from-input-field-without-filechooser. Follow the changes: See the changes made in InAppBrowser class from plugin version 3.0.0 1 - include imports:
2 - declare variavel;
3 - Replace onShowFileChooser code
4 - create method
5 - Replace onActivityResult
|
I tried adding this code, but it has no effect. when clicking browse, it still shows the file manager. I don't have too much with android plugins. any ideas? |
Please, try add permissions in config.xml
|
now,I found another question,I has opened the camera,when i sure choose the picture,I get the imagePath in "callbackFromNative" method in MainActivity ,but not in inappbrowser. so I can't use the imagePath in the pages of inappbrowser. |
Does not have a reference in input field? I have not yet reached this level in the application. I just trusted that image was in the input field. To find this solution was too hard, don't make me sad :( |
Still getting permission denied.
I tried adding those permissions, but I still get the permission error. I researched a little bit and changed the createImageFile method to use the WebView.GetConext() to get the private cache folder for the app. I now get a popup sliding up from the bottom of the screen with “Select Image” in a different language than English. The pop up has a camera and file icon. When I tap on the camera, nothing happens.
We need to make this as secure as possible. I don’t have more time to research, but would be possible to delete the stored file just after “uploading” it and to only allow capturing the image from the camera?
From: Gilberto Alexandre <notifications@github.com>
Reply-To: apache/cordova-plugin-inappbrowser <reply@reply.github.com>
Date: Tuesday, January 29, 2019 at 7:28 PM
To: apache/cordova-plugin-inappbrowser <cordova-plugin-inappbrowser@noreply.github.com>
Cc: Scott Gross <sgross@immerge.com>, Manual <manual@noreply.github.com>
Subject: Re: [apache/cordova-plugin-inappbrowser] Can not open camera when I click input type="file" on Android devices (#328)
Please, try add permissions on config.xml
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#328 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AEhhogEhz23gdWgLEUylcNPZEJ6jKBEbks5vIQNGgaJpZM4X35k6>.
|
To solve the permission's issue, go to App Configuration (configurations > apps > you app> permissions) and manually allow the permissions, and try again. If it works, the next step is change code to request permission automatically. About erasing the image's files, probably it's possible. But I have no time yet to try this. But I'm sure that I gonna need it. |
were able to open the camera via the input file? |
Yes, through the input file, I was able to access the gallery and choose between image and camera, and take photo. |
Dude I could not through inappbrowser, could you send me the plugin file, to replace in my app? Here only opens the file explorer. |
Sorry, I don't have access to project anymore, but you can try the changes recommended on https://stackoverflow.com/questions/26381050/choose-camera-in-file-upload-in-cordova-application-on-android-without-using-cor/54425770#54425770 (at Jan 29 at 16:42) |
I've already changed that guy and keep opening only the file explorer, did you change it in plugins / inappbrowser? And which Android did you test is this solution? |
Yes, I downloaded the plugin version 3.0.0 from the plugin and changed the .java files that were in plugin's folder. The tests were performed on Android 7 and 8 |
I am testing on android 5.1 and 6.0 here and it is not working. I'll test on Android 7 and 8 here. I made the modifications in the InAppBrowser.java file in the plugins / inappbrowser folder in ionic 3. |
I also tried on android 7 and 7.1 and continue to open only the file explorer, it does not open the camera. |
Você concedeu a permissão para a aplicação nos aos recursos?
Enviado do Yahoo Mail no Android
<div>Em qua, 8 8e mai 8e 2019 às 14:31, jeffersonveloso</div><div><notifications@github.com> escreveu:</div>
I also tried on android 7 and 7.1 and continue to open only the file explorer, it does not open the camera.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, I followed everything as stated above and in the post that you indicated me and when I click on some input file in the in app browser continues opening the file explorer. |
I still no solution here, man? Any suggestion? I have already tested on all android and continues to open the file explorer. |
Please, install cordova-plugin-inappbrowser@3.0.0 in you ionic app and replace the content file node_modules\cordova-plugin-inappbrowser\src\android\InAppBrowser.java with below code. Try app and give feeback, ok?
|
Você executou o build? Talvez apagar toda a pasta platform e adicioná-la novamente funcione. se você alterou na pasta que indiquei, é possível que não tenha atualizado platform. Eu tenho certeza que isso funciona, implantei o sistema com isso há uns 3 meses. A versão do ionic 3, cordova 8. |
Dude I created a new project in ionic 3 using Cordova 8.1.2. I added the plugin inappbrowser using the command cordova ionic cordova plugin add cordova-plugin-inappbrowser and then added the modifications in the directory you indicated. I made the plugin call like this: declare var cordova: any; const browser = cordova.InAppBrowser.open ('link', '_ blank'); Then I ran the build and continued as if I had not inserted modifications to the plugin, same behavior opening the file explorer. |
This worked for me. thanks a lot @gilbertogwa ! |
This worked for me. Thanks a lot @gilbertogwa ! |
@KenCorbettJr Will make a pull request tonight of my edited/working version with credits to @davidrevo |
@KenCorbettJr made the PR with my version, this all was pretty new for me. Hoping that the people who are working on this plugin are nice to me 😃 |
When testing the last version, camera indeed opens but file field is not populated with the captured image. Strange enough the same issue occurs when an image is selected from the gallery. With the formal 3.0.0 version gallery selection works. Any thoughts what could be the issue? @davidrevo |
Hi, I wonder if this is related, I have opened Amzon.com using inAppBrowser but when I click on the camera or microphone Icon, I get the following error, it it possible to get this working? |
This doesn't seem relevant to the main issue, looks like an error on the Amzon.com side 🤔 |
no Amazon website is fine. Chrome can open the camera. |
@davidrevo @PlanB007 Hi, thank you for your input. The cordova inappbrowser invokes the camera now. Unfortunately, once the video or picture is taken it is not being captured in the form. I tried http://regular-rod.surge.sh as a url. I'd appreciate your input in this. Thank you. |
@albosta @shlomoco After some debugging i managed to get it working, maybe it can be of some help to you. |
Actually I was still having the same issue with image not loading on Android 10 and in some devices not even opening the camera, the problem was that the code for the temporary file creation in here: private File createImageFile() throws IOException{
@SuppressLint("SimpleDateFormat") String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "img_"+timeStamp+"_";
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
return File.createTempFile(imageFileName,".jpg",storageDir);
} I changed the Environment.getExternalStoragePublicDirectory as it is deprecated on API 29 onwards, using this: private File createImageFile() throws IOException{
@SuppressLint("SimpleDateFormat") String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "img_"+timeStamp+"_";
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// let's use the new api for accessing external storage on 29 onwards
File storageDir = this.cordova.getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File file = new File(storageDir, imageFileName + ".jpg");
return file;
} else {
// was working well on older droids so let's leave it as is.
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = File.createTempFile(imageFileName,".jpg",storageDir);
return file;
}
} Thought I just left this here in case someone else is having the same struggle. |
Are there any news on this issue? It's still a big problem for me using the newest version of InAppBrowser. Normal chrome does it right but IAB opens filemanager instead of camera, even though the input says it should use camera. |
This comment has been minimized.
This comment has been minimized.
@ReneDyhr The above changes can also be applied to 5.0.1-dev. What I changed in src/android/InAppBrowser.java was: Add:
Add: Change onShowFileChooser to:
Note that I did not include Android < 5.0 for onShowFileChooser Add:
Credits to the people above |
you are the best :D |
…apture attribute relates apache#808 apache#328
Which classes should I put all of this code in? |
Still no progress on this? I am willing to use development branch, really need this feature :/ |
Hey team, just gave the InAppBrowser plugin a spin for PWA, Android, and iOS builds. Looks like the changes impacted IOS InAppBrowser functionalities, and for Android, it doesn't seem like we've cracked it yet. Any ideas? 🕵️♂️ |
We can not open device's native camera or see any option to open it when we clicked the input type="file" in Android devices. Is there any solution ?
The text was updated successfully, but these errors were encountered: