Share This:

So I was having a conversation today with someone. Who was curious on how to embed a website into a mobile application.  More specifically into an Android App. Oh though it really doesn’t matter. In my opinion the best way would be to use webkit technology.

In case you’ve been living under a rock for the past several years. Or maybe you have a strange allergy to the word Apple. Webkit is an open source platform created by Apple. Because it is created by Apple one may believe that webkit is restricted only to Apple products. However if this was true Apple wouldn’t be allowed to list it as Open Source. Since part of the definition requires the ability to allow people to modify the program to work on their preferred platform, such as Mac OSX, Windows, Linux, BSD, Solaris, Android, iOS. The exact wording in the definition is

9. License Must Not Restrict Other Software

The license must not place restrictions on other software that is distributed along with the licensed software. For example, the license must not insist that all other programs distributed on the same medium must be open-source software.




Rationale: Distributors of open-source software have the right to make their own choices about their own software.

Yes, the GPL v2 and v3 are conformant with this requirement. Software linked with GPLed libraries only inherits the GPL if it forms a single work, not any software with which they are merely distributed.

This is just one of the many great things about webkit, but their are thousands of other great things about webkit which is why so many programs and websites utilize it.

So now that we know a bit about webkit. We can use it to embed a website into a mobile application. Below I have listed a sample snippet of code that would display a website in mobile app.


WebView engine = (WebView) findViewById(R.id.web_engine);
engine.loadUrl("http://www.bigbenshosting.com");

Obviously their is a lot more code involved in order to make it into a mobile app. However the above to lines would be the only thing that you need to for your site to be in a mobile app.




Now how about adding some custom HTML code to the mobile app. After all their would be very few reasons why people would install an app if it is nothing more then the same website you can view on your phones web browser.


String data = "<html>" +
"<body><h1>My Mobile App</h1></body>" +
"</html>";
engine.loadData(data, "text/html", "UTF-8");

I know very easy aint it.