MAD Lab Mini Project Displaying Web Pages

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

JnanaSangam, Belagavi-590018

A MINI PROJECT REPORT ON


“DISPLAYING WEB PAGES”

BY
SOURABHA C DIXIT 4MT18CS101
TUSHARA SASI 4MT18CS107

UNDER THE GUIDANCE OF


Mr. Sunil Kumar S
Senior Assistance Professor
Department of CS & E,
MITE, Moodabidri

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


(NBA Accredited)
MANGALORE INSTITUTE OF TECHNOLOGY & ENGINEERING
(An ISO 9001:2015 Certified Institution)
BADAGA MIJAR, MOODBIDRI
D.KDIST-574225
2020-2021

1
MANGALORE INSTITUTE OF TECHNOLOGY & ENGINEERING
(AnISO9001:2015CertifiedInstitution)

BADAGA MIJAR, MOODABIDRI, D.KDIST.-574225

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


(NBA Accredited)

CERTIFICATE

This is to certify that Ms. Sourabha C Dixit(4MT18CS101), Ms. Tushara Sasi(4MT18CS107)


Has satisfactorily completed the mini project entitled “Displaying Web Pages” for the MAD
Laboratory with Mini Project (18CSMP68) lab as prescribed by the VTU for 6th semester B.E
Computer Science and Engineering branch for the academic year 2020-2021.

................................... ........................................
Mr. Sunil Kumar S Dr. P Venkatramana Bhat
Senior Assistance Professor HOD, Dept. of CSE,
Department of CS & E, MITE, Moodabidri
MITE, Moodabidri

Name of Examiners Signature of the Examiners

1. .............................. ...............................

2. .............................. ...............................

2
INDEX

TABLE OF CONTENTS Page No.

1. INTRODUCTION 5

2. LITERATURE WORK 6

2.1.1 ANDROID STUDIO 6

2.1.2 SQLite 6

2.1.3 JAVA 7

2.2 REQUIREMENTS 9

3. DESIGN 10

3.1 PROPOSED SYSTEM 10

3.2 SYSTEM FEATURES 10

4. IMPLEMENTATION 11

4.1 LOGIN JAVA 11

4.2 REGISTER JAVA 12

4.3 DATABASE-HELPER 14

4.4 WEBVIEW CONTROLLER 16

4.5 WEB PAGES 17

5. RESULTS 19

5.1 HOME PAGE 19

5.2 WEB PAGES 20


3
6. CONCLUSION 21

7. REFERENCES 22

4
1. INTRODUCTION

Mobile application development is the set of processes and procedures involved in writing software for
small, wireless computing devices, such as smart phones and other hand-held devices. Like web
application development, mobile application development has its roots in more traditional software
development. One critical difference, however, is that mobile apps are often written specifically to take
advantage of the unique features of a particular mobile device. In the early years of mobile apps, the only
way to ensure an app could perform optimally on any device was to develop the app natively. This meant
that new code had to be written specifically for each device's specific processor. Today, the majority of
mobile applications developed are device-agnostic.

In this project, users can get knowledge using this application. He or she can navigate through various web
pages. Users can create their own account and login to use this app. This app saves username and
password in a database created by admin.

5
2. LITERATURE WORK

2.1.1 ANDROID STUDIO:

Android Studio is the official integrated development environment (IDE) for Google's Android operating
system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development.
Which works on Windows, macOS and Linux based operating systems. It is a replacement for the Eclipse
Android Development Tools (E-ADT) as the primary IDE for native Android application development.
Android Studio supports all the same programming languages of IntelliJ ,e.g. Java, C++, and more with
extensions, such as Go and Android Studio 3.0 or later supports Kotlin and all Java 7 language features
and a subset of Java 8 language features that vary by platform version. External projects back port some
Java 9 features.

The code editor helps you write better code, work faster, and be more productive by offering advanced
code completion, refactoring, and code analysis. As you type, Android Studio provides suggestions in a
dropdown list. Simply press Tab to insert the code.

Android Studio's Apply Changes feature lets you push code and resource changes to your running app
without restarting your app—and, in some cases, without restarting the current activity. This flexibility
helps you control how much of your app is restarted when you want to deploy and test small, incremental
changes while preserving your device's current state.

2.1.2 SQLite:

SQLite is an in-process library that implements a self-contained, serverless, zero-


configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus
free for use for any purpose, commercial or private. SQLite is the most widely deployed database in the
world with more applications than we can count, including several high-profile projects.

SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a
separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database
with multiple tables, indices, triggers, and views, is contained in a single disk file. The database file
format is cross-platform - you can freely copy a database between 32-bit and 64-bit systems or
between big-endian and little-endian architectures. These features make SQLite a popular choice as

6
an Application File Format. SQLite database files are a recommended storage format by the US Library of
Congress. Think of SQLite not as a replacement for Oracle but as a replacement for fopen()

SQLite is a compact library. With all features enabled, the library size can be less than 600KiB, depending
on the target platform and compiler optimization settings. (64-bit code is larger. And some compiler
optimizations such as aggressive function inlining and loop unrolling can cause the object code to be much
larger.) There is a tradeoff between memory usage and speed. SQLite generally runs faster the more
memory you give it. Nevertheless, performance is usually quite good even in low-memory environments.
Depending on how it is used, SQLite can be faster than direct filesystem I/O. The SQLite code base is
supported by an international team of developers who work on SQLite full-time. The developers continue
to expand the capabilities of SQLite and enhance its reliability and performance while maintaining
backwards compatibility with the published interface spec, SQL syntax, and database file format. The
source code is absolutely free to anybody who wants it, but professional support is also available.

2.2.3 JAVA:

Java is a high-level, class-based, object-oriented programming language that is designed to have as few
implementation dependencies as possible. It is a general-purpose programming language intended to
let application developers write once, run anywhere (WORA), meaning that compiled Java code can run
on all platforms that support Java without the need for recompilation. Java applications are typically
compiled to byte code that can run on any Java virtual machine (JVM) regardless of the
underlying computer architecture.

The mobile edition of Java is called Java ME. Java ME is based on Java SE and is supported by most
smartphones and tablets. The Java Platform Micro Edition (Java ME) provides a flexible, secure
environment for building and executing applications that are targeted at embedded and mobile devices.
The applications that are built using Java ME are portable, secure, and can take advantage of the native
capabilities of the device. Java ME addresses the constraints that are involved in building applications that
are targeted at mobile devices. In essence, Java ME addresses the challenge of executing applications on
devices that are low on available memory, display, and power.

7
There are various ways to build applications for Android devices, but the recommended approach is to
leverage the Java programming language and the Android SDK. You can explore more about the Android
SDK Manager from here.

8
2.2 REQUIREMNETS

2.2.1 Hardware Specifications:

Processor : Intel i3/i5, 1.8GHz machine or above

Main Memory : 8GB RAM or more

Hard Disk : 160GB or above

Monitor : 64 bit

2.2.2 Software Specifications:

Operating System : Windows 10

Front End : Android Studio

Back End :SQLite, Java

9
3.1 DESIGN

3.1 Proposed System:

Many Android applications can be designed as a set of interactive screens linked with one another and
among which the user navigates. In the proposed system getting started with the Android WebView is
fairly simple, whether you want load a remote URL or display pages stored in your app. The graphical
interface proposes a picker which offers 4 choices ("Android", "Opengl", "Github" and “Java"), a OK
button and a web view which, at first, is not visible. Users can register and login to navigate through web
pages.

3.2 System Features

In the life of the software development, problem analysis provides a base for design and development
phase. The problem is analyzed so that sufficient matter is provided to design a new system. WebView
objects allow you to display web content as part of your activity layout, but lack some of the features of
fully-developed browsers. A WebView is useful when you need increased control over the UI and
advanced configuration options that will allow you to embed web pages in a specially-designed
environment for your app.

System Modules:
• Register page
• Login page
• DatabaseHelper
• WebView Controller
• Web page

10
3. IMPLEMENTATION

4.1 Login Java code:


package com.example.webpages;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Login_MainActivity2 extends AppCompatActivity {


Button btn_lregister, btn_llogin;
EditText et_lusername, et_lpassword;

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

databaseHelper = new DatabaseHelper(this);


et_lusername = (EditText)findViewById(R.id.et_lusername);
et_lpassword = (EditText)findViewById(R.id.et_lpassword);
btn_llogin = (Button)findViewById(R.id.btn_llogin);
btn_lregister = (Button)findViewById(R.id.btn_lregister);

btn_lregister.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
}
});

btn_llogin.setOnClickListener(new View.OnClickListener()
{
final Login_MainActivity2 context = Login_MainActivity2.this;
@Override
public void onClick(View v)
{

String username = et_lusername.getText().toString();

11
String password = et_lpassword.getText().toString();

Boolean checklogin = databaseHelper.CheckLogin(username, password);


if(checklogin == true)
{
Toast.makeText(getApplicationContext(), "Login Successful",
Toast.LENGTH_SHORT).show();
Intent i = new Intent(getApplicationContext(), homectivity2.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

}
else
{
Toast.makeText(getApplicationContext(), "Invalid username or password",
Toast.LENGTH_SHORT).show();
}
}
});
}

Code Description:

1. Using the above login.java code user can login to the application.
2. User will have to enter username and password used while registering.

4.2 Register Java Code:

package com.example.webpages;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

DatabaseHelper databaseHelper;
EditText et_username;
EditText et_password;
EditText et_cpassword;
Button btn_register, btn_login;

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

databaseHelper = new DatabaseHelper(this);


et_username = (EditText) findViewById(R.id.et_username);
et_password = (EditText) findViewById(R.id.et_password);
et_cpassword = (EditText) findViewById(R.id.et_cpassword);
btn_register = (Button) findViewById(R.id.btn_register);
btn_login = (Button) findViewById(R.id.btn_login);

btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,Login_MainActivity2.class);
startActivity(intent);
}
});

btn_register.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

String username = et_username.getText().toString();


String password = et_password.getText().toString();
String confirm_password = et_cpassword.getText().toString();

if (username.equals("") || password.equals("") || confirm_password.equals("")) {


Toast.makeText(getApplicationContext(), "Fields Required",
Toast.LENGTH_SHORT).show();
} else {
if (password.equals(confirm_password)) {
Boolean checkusername = databaseHelper.CheckUsername(username);
if (checkusername == true) {
Boolean insert = databaseHelper.Insert(username, password);
if (insert == true) {
Toast.makeText(getApplicationContext(), "Registered",
Toast.LENGTH_SHORT).show();
et_username.setText("");
et_password.setText("");
et_cpassword.setText("");
}
} else {

13
Toast.makeText(getApplicationContext(), "Username already taken",
Toast.LENGTH_SHORT).show }
} else {
Toast.makeText(getApplicationContext(), "Password does not match",
Toast.LENGTH_SHORT).show();
}
}
}
});
}
}

Code Description:

1. The above code is used in designing registration page.


2. All the user data will be stored in SQLite Database.

4.3 DatabaseHelper Java code:

package com.DataFlair.dataflairtodolist;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.DataFlair.dataflairtodolist.task_database.TaskContract;
import com.DataFlair.dataflairtodolist.task_database.TaskDatabaseHelper;
import com.google.firebase.auth.FirebaseAuth;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private TaskDatabaseHelper taskHelper;
private ListView TaskList;
private ArrayAdapter<String> arrAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

14
setContentView(R.layout.activity_main);

taskHelper = new TaskDatabaseHelper(this);


TaskList = (ListView) findViewById(R.id.list_todo);
updateUI();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);

return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_task:
final EditText taskEdit = new EditText(this);
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("Add a new task").setMessage("What do you want to do next?").setView(taskEdit)
.setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String task = String.valueOf(taskEdit.getText());
SQLiteDatabase db = taskHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(TaskContract.TaskEntry.COL_TASK_TITLE, task);
db.insertWithOnConflict(TaskContract.TaskEntry.TABLE, null, values,
SQLiteDatabase.CONFLICT_REPLACE);
db.close();
updateUI();
}
})
.setNegativeButton("Cancel", null).create();
dialog.show();
return true;

default:
return super.onOptionsItemSelected(item);
}
}
public void deleteTask(View view) {
View parent = (View) view.getParent();
TextView taskTextView = (TextView) parent.findViewById(R.id.title_task);
String task = String.valueOf(taskTextView.getText());
SQLiteDatabase db = taskHelper.getWritableDatabase();
db.delete(TaskContract.TaskEntry.TABLE, TaskContract.TaskEntry.COL_TASK_TITLE + " = ?",
new String[]{task});
db.close();
updateUI();

15
}
private void updateUI() {
ArrayList<String> taskList = new ArrayList<>();
SQLiteDatabase db = taskHelper.getReadableDatabase();
Cursor cursor = db.query(TaskContract.TaskEntry.TABLE,
new String[]{TaskContract.TaskEntry._ID, TaskContract.TaskEntry.COL_TASK_TITLE},
null, null, null, null, null);
while (cursor.moveToNext()) {
int idx = cursor.getColumnIndex(TaskContract.TaskEntry.COL_TASK_TITLE);
taskList.add(cursor.getString(idx));

}if (arrAdapter == null) {


arrAdapter = new ArrayAdapter<>(this, R.layout.todo_task, R.id.title_task, taskList);
TaskList.setAdapter(arrAdapter);

} else {
arrAdapter.clear();
arrAdapter.addAll(taskList);
arrAdapter.notifyDataSetChanged();
}
cursor.close();
db.close();
}
public void logout(View view) {
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(getApplicationContext(),Login.class));
finish();
}
}

Code Description:

1. The above main activity contains the code in saving the data onto the database. It is displayed
when certain queries are executed.

4.4 WebView Controller:

package com.example.webpages;

import android.webkit.WebView;
import android.webkit.WebViewClient;

// class is extended to WebViewClient to access the WebView


public class WebViewController extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {

16
// loadurl function will load the
// url we will provide to our webview
view.loadUrl(url);
return true;
}
}

Code Description:

1. This code is designed to so that code to use the URL of a website can be executed.

4.5 Web Pages:

package com.example.webpages;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.NumberPicker;

import androidx.appcompat.app.AppCompatActivity;

public class homectivity2 extends AppCompatActivity {

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

possibilities = findViewById(R.id.numberPicker);
webView = findViewById(R.id.webview);

String[] possibilitiesStrings = {
"Android Studio",
"Learn Github",
"Learn Java",
"Opengl Functions"

};
possibilities.setDisplayedValues(possibilitiesStrings);
possibilities.setMinValue(0);
possibilities.setMaxValue(possibilitiesStrings.length-1);

public void navigate(View view) {

17
int choice = possibilities.getValue();

if (choice==0) {
webView.loadUrl("file:///android_asset/android.html");
}else if (choice == 1)
webView.loadUrl("file:///android_asset/github.html");
else if (choice == 2)
webView.loadUrl("file:///android_asset/java.html");
else if (choice == 3)
webView.loadUrl("file:///android_asset/opengl.html");

}
}

Code Description:

1. In this code proposes a picker which offers 4 choices ("Android", "Opengl", "Github" and “Java"),
a OK button and a web view which, at first, is not visible

18
5. RESULTS:

5.1 FRONT END:


HOME PAGE: Home page consists of login/register for users to register and the later login to enter the
main activity page.

Fig.5.1 Login Page

Fig.5.2 Register Page


19
5.2 DISPLAYING WEB PAGES:

Users will be directed to thie page once they login, where they can use the application to enter all their
to-do list.

Fig.5.2.1 Displaying Web Pages

20
6. CONCLUSION:

Web Views are an indispensable part of apps nowadays. They let you quickly add a handy UI screen on the
fly by leveraging the skills of your web development team Web Views in Android might look the simplest
thing to implement, but there are a lot of details to consider. By leveraging the JavaScript-Android
interoperability, we can pass the data to Web Views from native Android code and vice versa as well.

A common scenario in which using WebView is helpful is when we want to provide information in your
app that we might need to update, such as an end-user agreement or a user guide. Within Android app, we
can create an Activity that contains a WebView, then use that to display your document that's hosted
online.

Another scenario in which WebView can help is if app provides data to the user that always requires an
Internet connection to browse through web pages. In this case, we can design a web page that's tailored for
Android devices and then implement a WebView in your Android app that loads the web page.

21
7. REFERENCES

[1] Front end (Login / Sign Up) code:


https://youtu.be/_5IIWUBzGbk
[2] SQLite Database:
https://youtu.be/_5IIWUBzGbk
https://sqliteonline.com/
[3] Back-end code:
https://www.coursera.org/learn/android-app/supplement/YT5oR/block-7-web-pages
https://www.geeksforgeeks.org/how-to-build-a-news-app-using-webview-controller-in-android-studio/

22

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy