KEMBAR78
Main Activity - Java: Android Manifest - XML | PDF | Personal Digital Assistant | Android (Operating System)
0% found this document useful (0 votes)
66 views3 pages

Main Activity - Java: Android Manifest - XML

This document contains code for an Android application that displays a webview loading the URL http://www.davbhagalpur.com. The MainActivity class finds the webview in the activity_main layout and enables JavaScript before loading the given URL. The Android manifest declares the MainActivity as the launcher and defines the internet permission needed to load web content.

Uploaded by

Vaibhav Amrit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views3 pages

Main Activity - Java: Android Manifest - XML

This document contains code for an Android application that displays a webview loading the URL http://www.davbhagalpur.com. The MainActivity class finds the webview in the activity_main layout and enables JavaScript before loading the given URL. The Android manifest declares the MainActivity as the launcher and defines the internet permission needed to load web content.

Uploaded by

Vaibhav Amrit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

Main Activity.

java

package com.example.vaibh.davpublicschoolbhagalpur;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {

private WebView mWebView;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mWebView = (WebView) findViewById(R.id.activity_main_webview);


WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.davbhagalpur.com");
}
}

Android manifest.xml

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.vaibh.davpublicschoolbhagalpur">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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


</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/activity_main_webview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />

</android.support.constraint.ConstraintLayout>

You might also like