HTML input type 'file' is not working on webview in android. Is there any way to upload file using webview android?

前端 未结 4 766
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 03:25

this is my browsing code of html.

This is my android code which load html file for browse file and upload on server.

        runOnUiThread(new R         


        
4条回答
  •  离开以前
    2020-12-14 03:48

    I'm new to Andriod and struggled with this also. According to Google Reference Guide WebView.

    By default, a WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored. If your goal is only to display some HTML as a part of your UI, this is probably fine; the user won't need to interact with the web page beyond reading it, and the web page won't need to interact with the user. If you actually want a full-blown web browser, then you probably want to invoke the Browser application with a URL Intent rather than show it with a WebView.

    Example code I executed in MainActvity.java.

     Uri uri = Uri.parse("https://www.example.com");
     Intent intent = new Intent(Intent.ACTION_VIEW, uri);
     startActivity(intent);
    

    Excuted

    package example.com.myapp;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.content.Intent;
    import android.net.Uri;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Uri uri = Uri.parse("http://www.example.com/");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
            getSupportActionBar().hide();
        }}
    

提交回复
热议问题