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() ?

Answer

It's possible to extract accept attribute with FileChooserParams.getAcceptTypes() for more details have a look at Android documentation.

The name attribute can be extracted with FileChooserParams.getFilenameHint() link to documentation.

For capture use FileChooserParams.getMode() as described in the documentation

There is another SO question regarding this issue and the actual code that could help.

  • 1
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions