Categories

Follow Us @web_learners

Saturday, April 4, 2020

How to Enable Download in Android Webview App | Webview App Development Series Part 10

How to Enable Download in Android Webview App? In the Last post of our Webview Series, I have shown How to Add Splash Screen in Any Android App. Webview doesn't support Download or Upload in App. Today I will show you how can you download any files, video, audio, pdf, image e.t.c file. In the next post, I will show you how to Enable Upload in Webview App. So, Let's Start.


First of all, you need to write a function that will ask users to give permission to access their photos, files, and media in their Mobile Phone. Because for saving the downloaded file on our mobile phone, the Download Manager needs to access it.

Code:



Now For handling download in webview, we need to write another function, in that function we will set notification visibility visible until download complete. Also, we will give saving file directory path "Download".


Code:




So, Whole final code will be in MainActivity.java file is :


Code:


After that, we need to go to AndroidManifest.xml for giving WRITE_EXTERNAL_STORAGE permission. (Don't forget this step otherwise, your app can be crashed)


Code:


We have finished our coding for Enabling Download in Webview, now I will run my project.




As you can see in the video and my screenshot of App, my website is about 25 types of social media free video downloader, and I have shown about Vimeo video download, as you can see all the function is working perfectly in my Webview App. I am recommending you to watch the above video for a better understanding. And if you face any problem in code or Error, don't hesitate to contact me. Thanks

2 comments:

  1. Mam, 2 options are available (Allow | Deny).Allow korle download to hochei but Deny korleo download hoche.Mam plus sometime no internet er page display hoche when I'm downloading.
    Ami dexter use kore deny problem ta slove kore niyeche but sometime no internet page ta asche.But mobile e data connected and download hoche.Pls help.

    ReplyDelete
  2. Thank you so much. Its very helping

    ReplyDelete