S
S
supportitc2020-02-07 14:28:27
Java
supportitc, 2020-02-07 14:28:27

How to make WebView open Input File - File Manager (photo selection) for uploading to the site?

I distribute permissions to the application in the manifest for (Internet / Camera and Storage):

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


I mark up the whole application in WebView in Activity Main

<WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />


And the Java CODE itself:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WebView myWebView = (WebView) findViewById(R.id.webview);
        myWebView.loadUrl("https://dodating.ru");

        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        myWebView.setWebViewClient(new WebViewClient());

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        myWebView.setBackgroundColor(Color.parseColor("#7d41f9"));

        myWebView.setPadding(0, 0, 0, 0);

    }

}


Everything works great, except for the file selection, it just doesn't bring up the file selection menu.

MNTzl.png

How to teach it to handle the file call button, as in the figure below?

99c2d2946a360f497e722ddffb8fd035.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gennady Furduy, 2020-02-07
@Xazan

Here it is described in detail: https://www.tutorialspoint.com/how-to-detect-click...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question