Android Working with WebView – Building a Simple In-App Browser

Build Basic Android Browser 

Android’s WebView allows you to integrate a webpage as a part of the app. WebView comes with all the features that of a desktop browser like managing history, cookies, HTML5 support and lot more. Using webview you can build very cool apps like integrating HTML5 games in the app.
In this article we are going to learn the basic usage of WebView starting from displaying a webpage to building a simple in-app browser that provides navigation and bookmark support. You will also learn how to use the WebView with other material elements like CollapsingToolbar and NestedScrollView to achieve the native android experience.


Download Above code in that you will get complete source code of Music Player.You need to be extract it and you will get it from following java files.


Java Files

Package : WebView\app\src\main\java\info\androidhive\webview

MainActivity.java
BrowserActivity.java
Utils.java

Important Notice is that in AndroidManifest.xml file use <uses-permission android:name="android.permission.INTERNET"/> permissions which are used to give the INTERNET permissions to our android application.

Androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="info.androidhive.webview" >

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar" >
        <activity android:name=".MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".BrowserActivity"
            android:theme="@style/AppTheme.NoActionBar"></activity>
    </application>
</manifest>

and you have all Layout support files in WebView\app\src\main\res\layout location
Open these project in Eclipse if you are not good with Eclipse generate gradle.build files from Eclipse then you can open that project in Android Studio.
Successfully You can develop your own android simple web browser..


If you have any doubts in above project please post your doubt in comment section as soon as possible.I will try to give you good solution.

No comments:

Send free SMS Text Messages with Python

Short Message Service (SMS) text messages are ubiquitous for communication all over the world. It is easy to send SMS text messages fro...

Data Science

WEB Development