![How To Create A Simple Web Browsing App For Android? How To Create A Simple Web Browsing App For Android?](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZJNlSvNXrX9AIYvjJ-kLF-YcfIosCxNdhLpNeV__bZB5TWyPY35l8v3rvw-VXtk2WJ2wiZ6z_lAmcCjvjnoZrEAyZ9Ux5Y8Rn7z_k9iEU_e62Mj_dMPhTtcBeC1qxj86eGtoY3y_GKB-W/s320/android+web+browsing+app.jpg)
Did you know that you can create a basic web browsing android app for your website with just a few lines of code? Web browsing Android apps are great if you have a nice website and you want to make your brand’s application with just a minimal amount of code. At the same time, it is a great way to learn more about Android application development, and it doesn't require a background in application development. So, in this tutorial, I will teach you how to create a basic web browsing app of your own!
Before moving on with this tutorial you should know, how to set up the SDK and must have understanding of creating a basic Android app. Here's what we've covered so far on the subject. Just bear with this tutorial, and if you have difficulty understanding a concept, then you can go back to any one of these previous tutorials.
Alright, let’s move on with the tutorial!
Creating a web browsing App for Android
Step 1: Create a new Android Application project
Using Eclipse create a new Android application project (“WebBrowsingApp”). For this tutorial I have selected API 16 (Jelly Bean).
![New Project New Project](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDBG-fVpShu1zsi5mHcCciGcDxMC5po5wX7vLLrmh81mSkRdaz7ZK1e_xCjysDZsV4-XJVQwaVHtcqM63YkD8j7uXTQ24r4-GO0fSLOGXwctJb0U0uJBSOIP-6Pu5nd3zApg7TekRsYux5/s1600/new-project.jpg)
Step 2: Edit activity_main.xml
Open “activity_main.xml” and add the following code:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
![Code Code](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnGiJZWMZz-kTwvj-VdczqOcdunBVawDFp5azadmfUxJpnnzTi83cTPngb8qUlDIsvfPPHmoi1dO4cqg6BLU1utmtvHipUCoxrmNTlA23rJrzulYIxLhbB5cqeewThprbMC15WcDl0LAsA/s1600/code.jpg)
Step 3: Edit AndroidManifest.xml
Open “AndroidManifest.xml” and add the following code, after manifest tag:
<uses-permission android:name="android.permission.INTERNET" />
![Code Code](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_U74uhY27RRareQycYJxSFDzq94PWpgGAsQvx1cO6v1_Lc9fdvpJk__nhFYjBrM1PYnr5nyiOsccuumd_nBNK5oeRF_nsAHCn2Lp8qFC9g0ASi1GYxr62M9S-4WX-oKNEieHek-wwOhrM/s1600/code.jpg)
Basically we’ve provided internet access to our application.
Step 4: Edit MainActivity.java
Finally edit “MainActivity.java”. Copy the following libraries:
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;
Now, overwrite the “public boolean onCreateOptionsMenu(Menu menu)” function with:
@SuppressLint("SetJavaScriptEnabled") @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl("http://www.mybloggertricks.com");
return true;
}
Your MainActivity.java class should look like this;
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_W98zNWFWWMPBHuGX6AsPo_iCpGFC_1TUrmSuZMhlkg_WXcxqniIh3oqur1FgGbuf-36IDsNaYALiWbGzwlFvCKaP_JmCuaG4l-8bGPVDllckZc7DH6fPCeMtTKmMgpYHjpbLsm0hI_T2/s1600/final+code.jpg)
Step 5: Execute
Now, it’s time to run our newly created web browsing app. Right click Project, and select Run as->Android application. It should look something like this.
![Finished App Finished App](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2VkOJSqM34GK3fA9Kph2Jj_xAT-i4kfCT-7pTafwj2ruVg-W9BxLmStNXeOf6UKTxVgWzcZ7VpAr0je99pKNKQ6Tjb6LVKh5YY2vZjxLi-8_YzvYQLlR4lcF_hbMJ5wRHyWh-gYejt8tR/s1600/final+app.jpg)
Pretty simple, right? You can add more functionality, and deliver your content in a much more optimized fashion to make your app much more mobile user-friendly.
If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »
Why not creating a chrome app or extention instead?
ReplyDeleteRegards!
Nice article Qasim! Keep it up!
ReplyDeleteWish I had found this blog before. The advices in this post are very helpful and I surely will read the other posts of this series too. Thank you for posting this.
ReplyDeletehey i have got some errors so please solve those
ReplyDelete1. activity_main cannot be resolved or is not a field
2. unexpected namespace prefix "xmlns" found for tag WebView
Hi,
ReplyDeleteCan I see adsense advertorial on webkit?
Thank you
Please provide the application link you used to make the browser
ReplyDeleteI have a problem. I used the above code and executed the apk successfully in my android phone (moto e 1st gen) but the browser is unable to loadUrl I specified in the MainActivity.java. What should i do to fix it? Please help.
ReplyDeleteI am using Android Studio 2.1.3