Forum Xamarin.Android


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to work with file uploader in webview in Xmarine.Android in c# application in visual studio

soumenhaldersoumenhalder Member ✭✭✭
edited October 2020 in Xamarin.Android

Hello, I am working in Xmarine.Android application in visual studio c#. Here I am working with webview. Everything is working fine but a input type= 'file' is not working but it is working in website perfectly so unable to upload profile image in from app. How to work with this.

protected override void OnCreate(Bundle savedInstanceState)
            webView = FindViewById<WebView>(Resource.Id.webView1);           

            WebSettings websettings = webView.Settings;
            websettings.JavaScriptEnabled = true;
            websettings.JavaScriptCanOpenWindowsAutomatically = true;
            websettings.AllowFileAccess = true;
            websettings.AllowContentAccess = true;
            webView.SetWebViewClient(new WebViewClientClass()); 

 public class WebViewClientClass : WebViewClient
        public override bool ShouldOverrideUrlLoading(Android.Webkit.WebView view, string url)
            return false;

in Manifest I used


Please help to upload image from webview in c# Xmarine.Android application.

Best Answer


  • soumenhaldersoumenhalder Member ✭✭✭

    I am calling a website from the webview. The website has the profile picture upload option. which is working fine from the website. but not working from webview. that is the problem. I have check the GIF that you have uploaded, but you have not load the URL like webView.LoadUrl(""); how to achieve that?

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    @soumenhalder I use local html just for testing, you can use your url to make a test, If we upload the image from local stroage to the html page, after that, you post this image to server is the same as the website.

  • soumenhaldersoumenhalder Member ✭✭✭

    @LeonLu Thank you Sir, for the support. This is working as perfect as I want.

  • soumenhaldersoumenhalder Member ✭✭✭

    Hello @LeonLu Sir , I am having a problem, with file upload event in web view app in VS 2019 c#, If I choose a image from my mobile storage then it is working fine, but If I do not select any image (just open the file chooser/ mobile storage) and press the back button and go back, then in OnActivityResult intent is having null value and then my file chooser is not working any more, means It is getting disabled.Then I need to close the app and need to reopen then it is working again. how to handle this, if I not choose any file.

    N.B. If I chose any file then it is working perfect.

Sign In or Register to comment.