MAD Lab Mini Project Displaying Web Pages
MAD Lab Mini Project Displaying Web Pages
MAD Lab Mini Project Displaying Web Pages
JnanaSangam, Belagavi-590018
BY
SOURABHA C DIXIT 4MT18CS101
TUSHARA SASI 4MT18CS107
1
MANGALORE INSTITUTE OF TECHNOLOGY & ENGINEERING
(AnISO9001:2015CertifiedInstitution)
CERTIFICATE
................................... ........................................
Mr. Sunil Kumar S Dr. P Venkatramana Bhat
Senior Assistance Professor HOD, Dept. of CSE,
Department of CS & E, MITE, Moodabidri
MITE, Moodabidri
1. .............................. ...............................
2. .............................. ...............................
2
INDEX
1. INTRODUCTION 5
2. LITERATURE WORK 6
2.1.2 SQLite 6
2.1.3 JAVA 7
2.2 REQUIREMENTS 9
3. DESIGN 10
4. IMPLEMENTATION 11
4.3 DATABASE-HELPER 14
5. RESULTS 19
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
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 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
Monitor : 64 bit
9
3.1 DESIGN
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.
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
DatabaseHelper databaseHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_main2);
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)
{
11
String password = et_lpassword.getText().toString();
}
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.
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;
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);
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) {
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:
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);
@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));
} 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.
package com.example.webpages;
import android.webkit.WebView;
import android.webkit.WebViewClient;
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.
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;
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);
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:
Users will be directed to thie page once they login, where they can use the application to enter all their
to-do list.
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
22