Convert mime types in fileChooserParams to the right format for Intent.setType

前端 未结 2 663
生来不讨喜
生来不讨喜 2020-12-16 07:13

I am trying to upload a file using a WebView in Android.

This is the code in use:

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean o         


        
2条回答
  •  孤城傲影
    2020-12-16 07:57

    I resolved simply adding the following 2 lines in my PR:

    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_MIME_TYPES, fileChooserParams.getAcceptTypes());
    

    Outcome:

    2019-04-01 00:18:00.501 32500-32500/my.app.bundle.id D/SystemWebChromeClient: : fileChooserParams.getAcceptTypes(): [.jpg,.png,.tiff,.jpeg,.tif,.pdf]

    2019-04-01 00:18:00.503 2225-2921/system_process I/ActivityManager: START u0 {act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=image/* cmp=com.android.documentsui/.picker.PickActivity (has extras)} from uid 10105

    I hope it will get accepted.

提交回复
热议问题