Dirty clean code. Creative Stuff. Stuff.
page loaded inside a
WKWebView. Today I will show you how to achieve the same result for tan Android Apps. I will a
part of the Android SDK called
I will use the same simple I used in the previous post for iOS. The html page contains a form with 2 input fields and a
button. We want to be able to read the form data inserted when the user clicks on the button and do some action on the
Java code side. In this sample case we will show a simple
AlertDialog that contains the form data. Let's start by
setting up the
Activity that will display the form,
MainActivity. The first thing to do is to setup the
declaring it in the activity layout. After that we can already setup the code that will load the web page in
onCreate method of the
The important thing to note in the code above is the
creating on the
Android. I will be able to use it by
window.Android.<some method>. Where are this method declared? As you can see the first parameter of the
showUser annotated with
window.Android object exposed on the web side.
So as you can imagine now I'm able to call the method
showUser inside the html page loaded in the
WebView. Let's see
the final implementation of the web page.
As you can see in the submit form we are calling the method we saw before annotated
You can find the complete code example in this github repository.
significantly improve the general user experiences.
robot: Android :robot:.
Better organize tests and run them against multiple configuration with Xcode Test Plan
Recently I added a lot of Unit and UI tests to RangeUISlider, one of my open source projects. Let's see how I grouped them and run them against multiple configurations with Xcode Test Plan.Read More
Unit testing in Kotlin with JUnit 5 and MockK
I recently discovered MockK, a mocking library created for Kotlin. Let's see how it is possible to write modern unit tests with MockK + JUnit 5.Read More
Spring Boot + Kotlin Rest client cheatsheet: RestTemplate and Webclient
During the last months I worked a lot with Spring Boot backend applications. In this post I explain how you can consume a REST api from a Spring Boot application using RestTemplate and (the new) WebClient.Read More