Change your web into mobile app


If you have a responsive website, and want to make mobile application for the same.
It's easy to go with web2app.

In xml layout file, take WebView control,


<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_world"
android:id="@+id/webview"
android:layout_below="@+id/progressbar"
android:layout_marginBottom="55dp"
android:layout_marginTop="2dp"
/> In Java file,
/**
**Initialize Webview
**/
WebView webView;

webView=(WebView)findViewById(R.id.webview);


        webView.setWebViewClient(new MyWebClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("");



Now define MyWebClient(), where you can handle webview start and stop loading event.


public class myWebClient extends WebViewClient
    {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            view.loadUrl(url);
            return true;

        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // TODO Auto-generated method stub
            super.onPageFinished(view, url);
         
        }



    }


For make your app more informative and useful, you can add 
Firebase analytics, admob, Contact Page and others.

Find the complete Project and updated webview in Github




Comments