问题描述
我们有一个混合应用程序,可在Android上运行并使用在MVC中创建的网络应用程序页面.
We have a hybrid app that runs on Android and using webapp pages created in MVC.
我们有2个按钮-1.文档上传-单击此选项后,文件,图库"选项应该可用(无相机选项)2.相机上传-单击此按钮应会触发手机中的相机应用.
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.
我在mvc视图上有以下代码:
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;">
在BrowserFragment.java中,我们有2个Intent:
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);
调用onShowFileChooser()时,如何根据页面上单击的按钮知道 takePhotoIntent 还是 chooseExistingPhotoIntent 来调用?
when onShowFileChooser() gets called, how do I know if takePhotoIntent to call or chooseExistingPhotoIntent to call based on the button clicked on page?
是否可以从FileChooserParams中提取值以确定哪个按钮正在调用onShowFileChooser()?
Is is possible to extract value from FileChooserParams to determine which button is calling onShowFileChooser() ?
推荐答案
可以使用FileChooserParams.getAcceptTypes()
提取accept
属性,有关更多详细信息,请参见 Android文档.
It's possible to extract accept
attribute with FileChooserParams.getAcceptTypes()
for more details have a look at Android documentation.
可以使用FileChooserParams.getFilenameHint()
链接到文档.
对于capture
,使用FileChooserParams.getMode()
文档中所述
关于此问题和可能有帮助的实际代码,还有一个 SO问题.
There is another SO question regarding this issue and the actual code that could help.
这篇关于调用onShowFileChooser()时如何从FileChooserParams中提取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!