Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

download any file in xamarin webview

$
0
0

can anyone help me download any file in my web view app or view any pdf from websites...this is the code is have in my main activity

using System.Linq; using System.Text; using Android.App; using Android.Views; using Android.Widget; using Android.OS; using Android.Webkit; using Android.Support.V4.App; using Android.Support.V7.App; using System; using Xfinium.Pdf; using Xfinium.Pdf.Graphics; using Android.Runtime; namespace HelloWebView { [Activity (Label = "UG MISWEB", MainLauncher = true , Icon = "@drawable/legon" , Theme = "@style/Theme.AppCompat.Light")]

public class MainActivity : Activity
{
    WebView web_view;
    protected override void OnCreate (Bundle bundle)
    {
        base.OnCreate (bundle);

        // Set our view from the "main" layout resource
        SetContentView (Resource.Layout.Main);

        web_view = FindViewById<WebView> (Resource.Id.webview);
        web_view.Settings.JavaScriptEnabled = true;
        web_view.LoadUrl ("http://pmis-1.ug.edu.gh:7771/pls/prodi01/w99pkg.mi_login");
        web_view.SetWebViewClient (new HelloWebViewClient ());
        web_view.Settings.AllowFileAccess = true;
        web_view.Settings.JavaScriptEnabled = true;
        web_view.Settings.JavaScriptEnabled = true;
        web_view.SetWebViewClient(new WebViewClient());
        web_view.SetDownloadListener(new MyDownloadListener());


        // allow zooming/panning
        web_view.Settings.BuiltInZoomControls = true;
        web_view.Settings.SetSupportZoom (true);

        // loading with the page zoomed-out, so you can see the whole thing (like the default behaviour of the real browser)
        web_view.Settings.LoadWithOverviewMode = true;
        web_view.Settings.UseWideViewPort = true;

        // scrollbar stuff
        web_view.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; // so there's no 'white line'
        web_view.ScrollbarFadingEnabled = false;
    }
    public override bool OnKeyDown (Android.Views.Keycode keyCode, Android.Views.KeyEvent e)
    {
        if (keyCode == Keycode.Back && web_view.CanGoBack ()) {
            web_view.GoBack ();
            return true;
        }

        return base.OnKeyDown (keyCode, e);



    }


        public class HelloWebViewClient : WebViewClient
        {
            public override bool ShouldOverrideUrlLoading (WebView view, string url)
        {
            view.LoadUrl (url);
            return true;
        }

            }
        }



    }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>