Professional Documents
Culture Documents
Ministry of Education
Prince Sattam Bin Abdulaziz University وزارة التعليم
College of Computer جامعة االمير سطام بن عبد العزيز
Engineering and sciences كلية هندسة وعلوم الحاسب
Department of Computer Sciences
قسم علوم الحاسب
Course Title and Code: Mobile Applications
:اسم الطالبة
development CS4831
Second Exam
Instructor Name: Dr. Ahmed Ghneimat
Semester I :الرقم الجامعي
Dr Aisha Abuduulahi
1439/1440
Date: 05-03-1440 H
:رقم الشعبة
Time: 60 minutes
Instructions تعليمات
▪ This exam consists of (2) questions on 3 pages. صفحات3 ) أسئلة على2( هذا االختبار مؤلف من ▪
▪ All questions should be answered on the same sheets
▪ Electronic devices that could have a memory is not
جاوب على جميع األسئلة على نفس االوراق ▪
allowed for theoretical part يمنع استعمال االجهزة االلكترونية التي تحتوي على ذاكرة ▪
▪ Traditional calculator is allowed للجزء النظري
▪ Examination rules must be adhered. )يسمح باستعمال االلة الحاسبة (دون ذاكرة ▪
● Books or other related materials are NOT allowed
.يجب االلتزام بجميع قوانين ولوائح االمتحانات ▪
● Use blue pen only
ال يسمح بالكتب أو المواد ذات الصلة داخل غرفة االمتحان ▪
الكتابة تكون بالقلم األزرق فقط ▪
3. To access a string resource called ‘day’, in a package that’s called android in java
a) R.android.string.day
b) String.android.R.day
c) android@R.string.day
d) android.R.string.day
b- Match the terms from the numbered column with statements in the second
1. R class 5 Used as an Alias to raw image files, and to specify additional properties
too
2. Explicit intents 3 Has a set of attributes to apply on a specific UI component
3. Style 6 Launch an activity expecting results upon its closure
4. onActivityResult 1 Automatically generated file, recreated if res/ directory is modified
5. XMLBitmap 2 Controls the application flow between activities in the same application
6. startActivityForResult 4 Used to handle the results sent from second activity
a) The activities design must be like the ones in the figure 1 (4 marks)
Set the application name to Chat Application
Define all the labels in the app as resources.
b) In the first activity (left), if the user clicks the ‘send’ button, the text in the edit text must be sent
to the second activity. (3 marks)
Note Copy the XML and Java file for each activity and upload it to the blackboard
Eaxm2
<resources>
<string name="app_name">ChatApplication</string>
<string name="send">Send</string>
<string name="textInit">Nothing is sent yet</string>
<string name="editHint">Enter your message here .. </string>
<string name="answer">Answer</string>
<string name="share">Share</string>
</resources>
activity_main.xml
<TextView
android:id="@+id/received"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/textInit"
/>
<EditText
android:id="@+id/sender"
android:hint="@string/editHint"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/send"
android:text="@string/send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="send"/>
</LinearLayout>
MainActivity.java
package com.example.satalites55.chatapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = findViewById(R.id.sender);
textView = findViewById(R.id.received);
activity_main2.xml
<TextView
android:id="@+id/sent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/receiver"
android:hint="@string/editHint"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/answer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="answer"
android:text="@string/answer" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="share"
android:text="@string/share" />
</LinearLayout>
Main2Activity.xml
package com.example.satalites55.chatapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;