Enable download ​from webview in Sketchware without code Injection

 It has been a while since the discovery of code injection technique in Sketchware and the code for enabling download from webview in Android has been known ever since.

But now I have discovered a way to enable download from webview in Sketchware, without injecting any external code or without rebuilding the app code with any other software. Given below is the step by step process.

1. If you are not using Sketchware, download it from the link provided. It is a great android app through which you can create you own android apps right from your mobile. Download Sketchware.

2. Start a new project in Sketchware.

3. In the view area, insert a Scroll(V) with layout_width set to match_parent. Inside the scroll(V) layout, insert a webview widget.

* I found later that not using Scrollview gives better results. WebView outside scrollview can be easily scrolled vertically and horizontally.

4. In Logic area of the project add the following events:
WebView: webview1 onPageStarted
WebView: webview1 onPageFinished

and also add an Intent component:
Intent download

5. Now go to onCreate event and add three string variables namely a, b, and c.

6. In onCreate event add the WebView loadUrl block and write the initial url to be loaded.
7. In onBackPressed event use following blocks:
If WebView webview1 canGoBack then
WebView webview1 goBack
8. In the event When webview1 pageStarted (url), add the following blocks:
set a to WebView webview1 getUrl
set c  to (url)
9. In the event When webview1 pageFinished (url), add the following blocks:
set b to WebView webview1 getUrl
If (a equals b) and not (c equals b) then
Intent download setAction ACTION_VIEW
Intent download setData c
StartActivity download

10. Now save and run the project. You will be able to download when you click on download links in your app.

Here is a video for better understanding of the logic:

If you like this then you are requested to share it. Also subscribe to my YouTube channel for more such logics.


  1. Hello! what of in the case of allowing your webApp to upload files when upload the upload button is pressed (upload in your website)

    please reply me here studyout2016@gmail.com

  2. Do we have to do the "If back pressed" thingy?

    1. The code in onBackPressed makes you go back to previous page in browse. If you don't add onBackPressed, app will exit on pressing back button.

    2. so can we have a button (not the back button) to do the job of the onBackPressed do we still have to have the onBackPressed?

    3. also when you do this non code ingestion way it actually opens those pages in the browser in the background

    4. Using codes gives better results.

      Also, it is better if you don't use Scrollview because webview itself is scrollable. Using scrollview hinders scrolling it laterally.

      If you don't use onBackPressed code, it finishes Activity on back pressed.

      You can use the code used in onBackPressed in any other event, like on Button Click or on Imageview Click or Textview Click.

  3. Nice....!!!Give Us More Tutroils..
    And Request Video Is How To Share And Open any other link:email,sms etc on webview

  4. It was awsome. Thankx for the

  5. Hi what I'm trying to do is to add an apk file to your sketchware application like images

    1. You can add app file in assets folder, using same method as this: https://youtu.be/SKRG9hEZS3k

    2. Hi..can you give me a way to make camera feature is usefull in the site i've open with webview.. this site adding barcode scanner and take photo button..

  6. How to enable search of word in webview.

  7. Action view can not resolved to a varible.. What to do??

    I follow exatly the same as u shown...

    1. That is Sketchware bug. Download latest version of Sketchware.

  8. Does this still work? I tried the code but I can't download a pdf file.

  9. Code is very bad. Why you should download in another app. You can download from your own app. Copy this code:
    webview1.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
    DownloadManager.Request request = new DownloadManager.Request( Uri.parse(url)); request.setMimeType(mimeType); String cookies = CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); request.addRequestHeader("User-Agent", userAgent); request.setDescription("Downloading File..."); request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType)); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir( Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName( url, contentDisposition, mimeType)); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); Toast.makeText(getApplicationContext(), "Download started", Toast.LENGTH_LONG).show();

    1. Your code requires app to request for storage permission before it works

  10. Good work, How to read and download or save PDF file from webpage on Sketchware. Pls teach me.


Post a Comment

Popular posts from this blog

Create Music Player app in Sketchware

A Flash Light App in Sketchware

Firebase auth in Sketchware for Login Activity

Simple car racing android game in Sketchware

In Sketchware: How to create a calculator for any simple formula?