第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法讓 android webview 在 android 9 上打開文件選擇器

無法讓 android webview 在 android 9 上打開文件選擇器

幕布斯7119047 2023-11-10 16:23:29
我正在嘗試type="file"在移動設備上的應用程序中打開輸入文件選擇器WebView,但處理同一問題的其他問題給出的解決方案適用于早期的 Android 版本,并且似乎不適用于 Android 9。問題似乎出在這段特定的代碼就在這里://For Lollipop 5.0+ Devices:  @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)    public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)    {        if (uploadMessage != null) {            uploadMessage.onReceiveValue(null);            uploadMessage = null;        }        uploadMessage = filePathCallback;        Intent intent = fileChooserParams.createIntent();        try        {            startActivityForResult(intent, REQUEST_SELECT_FILE);        } catch (ActivityNotFoundException e)        {            uploadMessage = null;            Toast.makeText(MainActivity.this, "Error: Unable to open file browser", Toast.LENGTH_LONG).show();            return false;        }        return true;    }
查看完整描述

1 回答

?
收到一只叮咚

TA貢獻1821條經(jīng)驗 獲得超5個贊

在這里使用此代碼修復。


        // For Lollipop 5.0+ Devices

        @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)

        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)

        {

            if (uploadMessage != null) {

                uploadMessage.onReceiveValue(null);

                uploadMessage = null;

            }


            uploadMessage = filePathCallback;


            Intent intent = fileChooserParams.createIntent();

            try

            {

                intent.setAction(Intent.ACTION_GET_CONTENT);

                intent.setType("image/*,video/*,audio/*,file/*");

                startActivityForResult(intent, REQUEST_SELECT_FILE);

            } catch (ActivityNotFoundException e)

            {

                uploadMessage = null;

                Toast.makeText(MainActivity.this, "Error: Unable to open file browser", Toast.LENGTH_LONG).show();

                return false;

            }

            return true;

        }


查看完整回答
反對 回復 2023-11-10
  • 1 回答
  • 0 關注
  • 209 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號