We have a hybrid app that runs on Android and using webapp pages created in MVC.
We have 2 buttons - 1. Document upload - Files, Gallery options should be available when this is clicked (no camera option) 2. Camera upload - clicking on this should trigger camera app in phone.
I have following code on mvc view :
<input type="file" id="uploadFile" name="files" accept=".pdf,.jpg,.jpeg,.gif,.png" style="display:none;" />
<input type="file" id="capture" name="LnFImage" accept="image/*" capture="capture" style="display:none;">
in BrowserFragment.java, we have 2 Intents:
Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Intent chooseExistingPhotoIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
when onShowFileChooser() gets called, how do I know if takePhotoIntent to call or chooseExistingPhotoIntent to call based on the button clicked on page?
Is is possible to extract value from FileChooserParams to determine which button is calling onShowFileChooser() ?
It's possible to extract
accept
attribute withFileChooserParams.getAcceptTypes()
for more details have a look at Android documentation.The
name
attribute can be extracted withFileChooserParams.getFilenameHint()
link to documentation.For
capture
useFileChooserParams.getMode()
as described in the documentationThere is another SO question regarding this issue and the actual code that could help.