You are on page 1of 7

Course Code CS367

Description Mobile Programming 2


College / Department:
Lab Exercise No. 8
Online Education

Laboratory Exercise 8 Page 1 of 7

EXERCISE

8
Webview-Based Application

I. OBJECTIVES

At the end of this exercise, students must be able to:

Cognitive
1
Course Code CS367

Description Mobile Programming 2


College / Department:
Lab Exercise No. 8
Online Education

Laboratory Exercise 8 Page 2 of 7


a.) Understand the topics they have learned from Lesson 10 - Android Mobile and Web Application.
.
Psychomotor:
a.) Design an Android application with webview layout.
b.) Fetch url linkhosted online
c.) Apply webview layout
d.) Construct a webview-based Android application

Affective
a.) Appreciate the concept behind this exercise.

II. BACKGROUND INFORMATION

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

III. LABORATORY PROCEDURE

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

Description Mobile Programming 2


College / Department:
Lab Exercise No. 8
Online Education

Laboratory Exercise 8 Page 3 of 7


TASK

1. Create a new Android Project.

Project Name: AndroidAppEight


Activity Name (Main): MainActivity

2. Design the activity main xml layout and integrate webview.

3. Edit the main activity java and add the url link.

4. Grant internet permission to the android manifest file.

3
Course Code CS367

Description Mobile Programming 2


College / Department:
Lab Exercise No. 8
Online Education

Laboratory Exercise 8 Page 4 of 7


5. Run and test the program

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

Description Mobile Programming 2


College / Department:
Lab Exercise No. 8
Online Education

Laboratory Exercise 8 Page 5 of 7


Activity_main.xml

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<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;

public class MainActivity extends 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

Description Mobile Programming 2


College / Department:
Lab Exercise No. 8
Online Education

Laboratory Exercise 8 Page 6 of 7

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

Description Mobile Programming 2


College / Department:
Lab Exercise No. 8
Online Education

Laboratory Exercise 8 Page 7 of 7

You might also like