Enable download from webview in Sketchware without code Injection
2 minute read
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:
onBackPressed
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
else
FinishActivity
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.
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:
onBackPressed
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
else
FinishActivity
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.