Mobile Application Assignment

MOBILE APPLICATION ASSIGNMENT 1

MobileApplication Assignment

StudentAffiliation

InstitutionAffiliation

MobileApplication Assignment

Q1.(2 Marks)

Explainin details the activity life cycle of an android application with thehelp of

Diagrams

Anactivity is a single focused occurrence that a given user canachieve. At least, all activities have the tendency to interact withthe user. The activity has a task of creating a User Interface withsetContent (view) (developer.android.com).

Activitiesin the system are managed as an activitystack.

Allactivities have 4 critical cycles:

  • Running or active:-The foreground of the screen contains the activity. It is found at the top of the stack (developer.android.com).

  • Paused:-The activity has misplaced (killed) its prime concentration but it is still alive. It is paused. It upholds all states and remains attached to the window manager (developer.android.com).

  • Stopped:-The activity is killed by another activity. It will retain all state and information but it’s no longer visible and thus its windows is hidden (developer.android.com).

  • Finish:-When the activity is stopped, the system will drop from memory by killing it or finishing it. If it’s to be displayed again, it should be restored to its previous state (developer.android.com).

The following diagram shows theactivity life cycle of an android application:

Figure1 Android Life Cycle

Q2. (1 Mark)

Whatare Adapters in android, explain different adapter views

Adaptersare platform that acts as a bridge between AdapterView and thefundamental data needed for that view. The adapter runs admission tothe data items. The Adapter has the sole purpose for developing aView for each element in the data set. Different Adapter views are(developer.android.com):-

  • ArrayAdapter

  • SimpleCursorAdapter

  • CursorAdapter

  • BaseAdapter

  • ListAdapter

Q3(1 Mark)

Explainthe Android location services and the classes required for gettingGPS location.

Applicationsin the Android are given an access to the location services sustainedby the gadget, by classes in the android. location package.Criticalconstituent of the location background is LocationManagersystemservice. It offers APIs to define location and bearing of the basicavailable device. Maps are be added to the Apps that are based onGoogle Maps data (developer.android.com),based on the&nbspGoogleMaps Android API.

Themain class in the Google Maps Android API is&nbspMapView.MapView&nbsppresentsa map, and the data is extracted from Google Maps service(developer.android.com).

Q4.(2 Marks)

a) Thefollowing figure shows a part of Android application manifest file.

//1

&ltmanifestxmlns:android=&quothttp://schemas.android.com/apk/res/android&quot

package=&quotcom.example.helloworld&quot

android:versionCode=&quot1&quot

android:versionName=&quot1.0&quot&gt

//2

&ltuses-sdk

android:minSdkVersion=&quot8&quot

android:targetSdkVersion=&quot17&quot/&gt

Discussin details what is meant by part number //1 and //2

//1 – The first line declares the start of the manifest along with aURL that holds a path which explains the usage of the namespaces.Package allows for naming of the project following java packagesystem. This will allow application from the same publisher to seaton the same path hierachy when the `.` (period) is considered as afolder separator.

com.adobe.illustrator com/adobe/illustrator

com.adobe.photoshop com/adobe/photoshop

com.adope.reader com/adope/reader

Versioncode holds the numerical representation of the current applicationversion while version name is the name of the current version.

//2– This declares the maximum (android:maxSdkVersion),minimum (android:minSdkVersion)and the target(android:targetSdkVersion)android sdk versions required to run this application. As shownabove, this application requires devices with android sdk 8 and aboveand is build with sdk 17. Currently it has no maximum sdk versionset.

b) Inthe previous figure, what changes are required to do if you made anew version of your application “1.1”, also a new SDK version 18is available

&ltmanifestxmlns:android=&quothttp://schemas.android.com/apk/res/android&quot

package=&quotcom.example.helloworld&quot

android:versionCode=&quot2&quot

android:versionName=&quot1.1&quot&gt

//2

&ltuses-sdk

android:minSdkVersion=&quot8&quot

android:targetSdkVersion=&quot18&quot/&gt

Q5.(4 Marks)

Inthe following activity, complete the following code in order thatwhen a user

pressADD button the sum of the two numbers in (txtnum1, txtnum2) willappear

in(tviewresult).

finalEditText txtNum1 = (EditText)findViewById(R.id.txtnum1)

finalEditText txtNum2 = (EditText)findViewById(R.id.txtnum2)

finalTextView lblResult = (TextView)findViewById(R.id.tviewresult)

finalButton btnAdd = (Button)findViewById(R.id.button)

btnAdd.setOnClickListener(newOnClickListener() {

@Override

publicvoidonClick(View v) {

floatfloat_1 = Float.parseFloat(txtNum1.getText().toString())

floatfloat_2 = Float.parseFloat(txtNum2.getText().toString())

lblResult.setText(Float.toString(float_1+float_2))

}

})

References

Retrieved28 Oct, 2015 fromhttps://developer.android.com/guide/topics/location/index.html