How To Make A Browser App For Android using Android Studio
Before I proceed further, here is the screenshot of the kind of browser that’ll be create using Android Studio.
You can open any website with it as we have requested for Internet Permission and Access Network State in the Android Manifest file, however, downloading is not allowed as the permission for same isn’t requested. To know more about working with Permissions in Android, click here.
Here are few more things to know before I proceed further:
Android Studio (Version 3.x)
Here are the Steps you need to follow now:
Steps on How To Make A Browser App For Android
1.Open Android Studio and create a new project with Application name as, ‘FIMC Browser’ (you can use any of your choice!).
2. We have used API level 19 in our project as 90% devices support this, click next and select to create an Empty Activity.
3. Once Gradle build is completed, go and select Project Panel on the left and go to App > src > main > res and open AndroidManifest.xml file.
4. In AndroidManifest.xml file, above <application>, request for Internet and Access Network State permission. This can be done by writing following lines of code:
14. Now let’s create the basic layout of our Browser App. For this head to ‘activity_main.xml’ file and change Constrain layout to Linear Layout. Then add a Horizontal Progress bar to it. After this, inside the LinearLayout, we have added Relative layout in which, the EditText field for Web Address and Button is added. Once this is done, Relative Layout Tag is closed and inside Linear Layout, WebView is inserted. WebView is used to display Web pages. We will be altering some of WebView settings in MainActivity.java file later in this tutorial.
15. Complete code for ‘activity_main.xml’ is here:
20. Now in MainActivity.Java, I have created a public class with name ‘ourViewClient‘ that’ll extent WebViewClient. In ‘ourViewClient’ class we will override some methods of WebViewClient. The shouldOverrideUrlLoading() method will give the host application a chance to take over the control when a new URL is about to be loaded in the current WebView.
21. Later in the code, menu.xml file is inflated and buttons are inflated in the title bar.
22. The complete code for ‘MainActivity.xml’ file can be found here:
Now your own personal Browser App is ready, Build and run in on your Device. Let us know how did you like our How To Make A Browser App For Android blog in the comment section below and follow rest of the Roadway to Android Development Tutorialseries here.