Professional Documents
Culture Documents
EXERCISE
8
Webview-Based Application
I. OBJECTIVES
Cognitive
1
Course Code CS367
Affective
a.) Appreciate the concept behind this exercise.
In order to accomplish this exercise, the student must have a clear understanding of the following topics:
Android Mobile and Web Application
Webview class
Adding Internet Permission
Overview
This programming exercise demonstrates the implementation of WebView in your android application.
It contains a webview that displays the document that’s hosted online.
2
Course Code CS367
3. Edit the main activity java and add the url link.
3
Course Code CS367
All laboratory activities and machine problems are required to be submitted with the following:
the source codes, the screenshot of the output, and the apk file(debug apk), all compressed in .rar or .zip format.
4
Course Code CS367
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Main_activity
package com.example.androidappeight;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = findViewById(R.id.webView);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl("https://www.ama.edu.ph/");
WebSettings webSettings= myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
}
Androidmanifest.xml
5
Course Code CS367
There are no errors with the source codes. However, there seems to be a problem with my emulator that it
doesn’t launch the android app eight. Maybe if you will try on your end, it will work.
6
Course Code CS367