Android WebView App (to Apache server)


Just successfully created my first Android App.

So I have been playing around recently with modifications, improvements and configurations on my current project – “Smart Home using Raspberry Pi & Android with Voice Recognition.”

I have been thinking of implementing a simple Android application which directly opens up URL, rather than going to my browser each and every time I need to access the web control server(Apache2).

So one might be wondering what is exactly this WebView ‘nonsense’ a simple Google search gave me this definition, A “webview” is a browser bundled inside of a mobile application producing what is called a hybrid app. Using a webview allows mobile apps to be built using Web technologies (HTML, JavaScript, CSS, etc.) but still package it as a native app and put it in the app store.

Now coming back to the App, i’m using the latest Android Studio, source code below.


//__author__ = "Mpho Mphego"
//__description__ = "Android WebView App controlling Raspberry Pi running Apache2"
//__version__ = "Revision: 1.0 "
//__date__ = "Date: 2015/01/17 22:23 "
//__url__ = ""
//__copyright__ = "Copyright (c) 2015 Mpho Mphego"
//__license__ = "Java"

package com.wordpress.mpho112.mobilehomectrl;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MainActivity extends ActionBarActivity {
    private WebView mWebView;

    protected void onCreate(Bundle savedInstanceState) {
        mWebView = (WebView) findViewById(;
        // Enable Javascript
        WebSettings webSettings = mWebView.getSettings();

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == {
            return true;

        return super.onOptionsItemSelected(item);


<FrameLayout xmlns:android=""

        android:layout_height="match_parent" />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s