Sie sind auf Seite 1von 20

Coursework Title:

COMP1661 Application Development for Mobile Devices -


Logbook

Due date: 12th April 2018

Student Name: Nguyen Ngoc Chan

Student ID: GT60826

1
A. Exercise 1:
1) Basic information

1.1 How well did you complete the  I tried but couldn't complete it
exercise? Tick as appropriate.  I did it but I feel I should have done better
 I did everything that was asked
 I did more than was asked for
1.2 Briefly explain your answer to In this exercise, I have design a Phonegap application
question which can show notification such as ring the phone,
vibrate the phone. Moreover, there is a button when
user click the button, it will navigate to the next page
and show network status.

2) Exercise answer
a) Screen shots of program

Home Screen

2
Second Screen

b) Screen shots of code


Screen shot of First Page Code

Head

3
Script

Html body

4
Screen shot of Second Page Code

Head

Script

5
Body

6
B. Exercise 2
1) Basic information

1.1 How well did you complete the  I tried but couldn't complete it
exercise? Tick as appropriate.  I did it but I feel I should have done better
 I did everything that was asked
 I did more than was asked for
1.2 Briefly explain your answer to In this exercise, I have design a Phonegap application
question which has two pages. The first page shows a form which
allows user to enter their activity’s information, this
form also has validation on three required fields. After
user entering their information, the application will
navigate to the second page and show their information.

2) Exercise answer
a) Screen shots of program

Home Screen

7
Second Screen

b) Screen shot from the Blocks Editor to show the code


Screen shot of First Page Code

Head

8
Script

9
Body

Screen shot of Second Page Code

Head

10
Script

11
Body

12
C. Exercise 3
1) Basic information

1.1 How well did you complete the  I tried but couldn't complete it
exercise? Tick as appropriate.  I did it but I feel I should have done better
 I did everything that was asked
 I did more than was asked for
1.2 Briefly explain your answer to In this exercise, I have design a Phonegap application
question which can create a database and table to store
information for iVolunteer application, the name of
database is DatabasePhonegap and the name of table is
activities. The table has eight fields to store the
information of volunteer and review also, it includes id,
name, date, time, location, volunteer, review and photo.

2) Exercise answer
a) Screen shots of program

Home Screen

13
b) Code

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-
scalable=no, width=device-width">
<title>Blank App</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.center {
margin: auto;
width: 60%;
text-align:center;
padding: 10px;
}
body {background-color: #F0F8FF}
</style>
</head>
<body >
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {

var db = window.sqlitePlugin.openDatabase({name:
"mySQLite.db", location: 'default'});
db.transaction(populateDB, errorCB, successCB);
}
function populateDB(tx) {
tx.executeSql(
'CREATE TABLE IF NOT EXISTS activities \
( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
name TEXT NOT NULL,date text not null, location text ,\
time text , volunteer text not null, review text, photo text );');
}
function errorCB(tx, err) {
alert("Error processing SQL: "+err);
}

14
function successCB() {
document.getElementById("msg").innerHTML ="Database has
been created!";
}
function closeapp()
{
navigator.app.exitApp();
}
</script>
<br/><br/><br/><br/>
<br/><br/><br/><br/>
<div class="center">
<p id="msg"></p>
</div>
<br/><br/><br/><br/>
<div class="center">
<p>Press button "Close" will close this application</p>

<button onclick="closeapp()" class="btn btn-warning"


type="button" >
<span class="glyphicon glyphicon-remove-sign"></span>
Close</button>

</div>
<br/><br/><br/><br/>
</body>
</html>

15
D. Exercise 4
1) Basic information

1.1 How well did you complete the  I tried but couldn't complete it
exercise? Tick as appropriate.  I did it but I feel I should have done better
 I did everything that was asked
 I did more than was asked for
1.2 Briefly explain your answer to In this exercise, I have design an Android native
question application. I added the button “Don’t Press Me” on the
first screen of the MainActivity, when the button is
clicked, the second screen of the Main2Activity is shown
with a message “Why did you do that?”

2) Exercise answer
a) Screen shots of program

Home Screen

16
Second Screen

b) Code

package nameentry.uni.greenwich.com.nameentry;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.btnclick);
btn.setOnClickListener(new View.OnClickListener() {
@Override

17
public void onClick(View view) {
Intent intent= new Intent(MainActivity.this,
Main2Activity.class);
startActivity(intent);
}
});
}
}
First Activity

<?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="nameentry.uni.greenwich.com.nameentry.MainActivity">
<Button
android:id="@+id/btnclick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Don't Press Me"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
First Activity XML Layout

18
package nameentry.uni.greenwich.com.nameentry;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Main2Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
}
Second Activity

<?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="nameentry.uni.greenwich.com.nameentry.Main2Activity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Why did you do that?"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

Second Activity Layout XML

19
References
(1) "Apache Callback Proposal". Wiki.phonegap.com. 2013-08-15. Retrieved 2013-10-09.
(2) "Cordova Contributor's Who's Who". apache.org. 2015-11-02. Retrieved 2015-11-02.
(3) Darryl K. Taft (2009-03-13). "PhoneGap Simplifies iPhone, Android, BlackBerry
Development". Eweek.com. Retrieved 2013-10-09.
(4) "android/platform/bionic/". Archived from the original on December 17, 2017.
(5) "android/platform/external/mksh/". Archived from the original on January 21, 2016.
(6) "android/platform/external/toybox/toys/". Archived from the original on March 14,
2016.
(7) "Android gets a toybox". Archived from the original on March 4, 2016.
(8) Jump up^ "android/platform/system/core/toolbox/". Archived from the original on
February 9, 2014.

20

Das könnte Ihnen auch gefallen