I made a hybrid app on Nuboard 5, but the attached file is not pressed in Android studio webview... crying

Asked 2 years ago, Updated 2 years ago, 22 views

Android Studio is API 16: Android 4.1 (jelly Bean)

I'm using it.

The webview says to use Chrome client, but no matter how hard I try... It's hard.

It's been successful, but cameras and other functions are not being used.

I've been looking into it for a week, but it's too hard.

I think it's really nice that the people here explained the answers so easily^

^

If you know how to code, I would appreciate it if you could tell me a little bit.

android gnuboard

2022-09-22 11:00

4 Answers

The reason why the Attach File button does not work in Web View is because there is no related implementation. It should be implemented using the WebChrome Client. Please refer to the links below.

There is a hassle that file attachment processing in Android webview requires branching by OS version, but it is not impossible. It's already being processed in many apps, and there's a lot of data. I recommend you to follow along one by one. I left a link because there was a similar question in the hash code.


2022-09-22 11:00

public void openFileChooser();

The above function is invoked when you click <input type="file" /> on the web. In the code you uploaded, the activity to select the image file is executed using the startActivityForResult() function. In other words, it would be easy to understand that it is the part that floats the file dialog.

protected void onActivityResult();

The above function is a function that receives the result value of the activity executed with startActivityForResult(). Since I executed the file dialog, I think you can understand that when a user selects an image, the Uri of the image is delivered. In the code you uploaded, the process of delivering the image file path (Uri) selected by the user to the web view is performed.

Be sure to read the Start Activity for Results section at the following link.


2022-09-22 11:00

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Called when the activity called with startActivityForResult ends!

    if (requestCode == FILECHOOSER_NORMAL_REQ_CODE) {
        if (filePathCallbackNormal == null) return ;
        Uri result = (data == null || resultCode != RESULT_OK) ? null : data.getData();
        filePathCallbackNormal.onReceiveValue(result);
        filePathCallbackNormal = null;
    } } else if (requestCode == FILECHOOSER_LOLLIPOP_REQ_CODE) {
        if (filePathCallbackLollipop == null) return ;
        filePathCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));
        filePathCallbackLollipop = null;
    }
}

Among the contents you sent me, Here's the code.
I just don't understand this part I understand everything. Can you help me with this?crying I'm getting a lot of help. Thank you.


2022-09-22 11:00

public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType) {
                Log.d(TAG, "3.0+");
                filePathCallbackNormal = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*"); // vidio/* audia/*
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_NORMAL_REQ_CODE);}

I don't know about this place either. Tell me


2022-09-22 11:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.