0% found this document useful (0 votes)
34 views5 pages

Question 3

The document outlines key concepts in Android development, including Intent types (explicit and implicit), API levels, and the role of frameworks. It also compares SOAP and REST web services, discusses Android permissions, and explains the use of Gradle and SMS functionalities. Additionally, it covers methods for starting activities, checking EditText fields, and the importance of image resolutions in Android applications.

Uploaded by

kajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views5 pages

Question 3

The document outlines key concepts in Android development, including Intent types (explicit and implicit), API levels, and the role of frameworks. It also compares SOAP and REST web services, discusses Android permissions, and explains the use of Gradle and SMS functionalities. Additionally, it covers methods for starting activities, checking EditText fields, and the importance of image resolutions in Android applications.

Uploaded by

kajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Question 01 [20 Marks]

a) What are the two main Intent types in Android? (4 marks)

 Explicit Intent
 Implicit Intent

b) Briefly explain the Intent types mentioned in part (a). (6 marks)

 Explicit Intent:
o Used to launch a specific activity within the same app.
o Example: Navigating from MainActivity to SecondActivity.
 Intent intent = new Intent(MainActivity.this, SecondActivity.class);
 startActivity(intent);
 Implicit Intent:
o Used to perform general actions without specifying the target component.
o Example: Sharing content with available apps.
 Intent intent = new Intent(Intent.ACTION_SEND);
 intent.setType("text/plain");
 startActivity(intent);

c) What does API level identify in Android? (6 marks)

 API Level defines the version of the Android framework an application targets.
 It determines:
o The available features.
o Compatibility with older devices.
o Minimum and maximum version support for apps.

d) What does a framework provide to help programmers? (4 marks)


A framework provides:

 Reusable components for faster development.


 Built-in libraries for UI design and data management.
 Code organization tools like activities, fragments, and services.
 Simplified testing and debugging tools.

Question 02 [20 Marks]

a) State eight differences between SOAP web services and REST web services. (8 marks)
Aspect SOAP REST
Protocol Uses its own XML-based protocol Uses HTTP
Data Format XML only JSON, XML, Plain text, HTML
Complexity More complex, strict structure Simpler and flexible
Performance Slower due to XML parsing Faster due to lightweight data
State Management Stateful or Stateless Stateless
Security WS-Security standard supported Relies on HTTPS for security
Use Case Enterprise-level applications Web and mobile applications
Error Handling Standardized error handling Simplified error messages

**b) Write down the XML coding to create a string variable. The name of the variable should
be print_message, and the value should be "Enter Full Name" (2 marks)

<string name="print_message">Enter Full Name</string>

c) What does the findViewById() method do in the following code statement? (2 marks)

Button clickButton = findViewById(R.id.button);

 findViewById() retrieves the UI element with the specified ID (R.id.button) and


links it to the clickButton object for interaction.

d) Describe normal permissions and dangerous permissions with examples. (8 marks)

 Normal Permissions:
o Access resources with minimal risk.
o Automatically granted.
o Example: ACCESS_WIFI_STATE (Check Wi-Fi state).
 Dangerous Permissions:
o Access sensitive data or device features.
o Explicit user approval required.
o Example: READ_CONTACTS (Access contacts).

Question 03 [20 Marks]

a) What does Gradle do in Android Studio? (4 marks)

 Gradle is a build automation tool used in Android Studio. It helps with:


o Managing project dependencies.
o Automating build processes.
o Compiling code and packaging the APK.
b) What class is used to send SMS messages programmatically in Android? (2 marks)

 SmsManager

c) What are the Android application permissions required to send and receive SMS? (2
marks)

 android.permission.SEND_SMS
 android.permission.RECEIVE_SMS

d) Write the Java code for the following tasks.

i. Create a TextView type object named textMessage and link it with the UI. (4 marks)

TextView textMessage = findViewById(R.id.Email);

ii. Create an EditText type object named textPhoneNum and link it with the UI. (4
marks)

EditText textPhoneNum = findViewById(R.id.Phone);

iii. Create a Button type object named btnSendSms and link it with the UI. (4 marks)

Button btnSendSms = findViewById(R.id.next_btn);

Question 04 [20 Marks]

a) What method starts an activity with an Intent? (4 marks)

 startActivity() method.

b) Is there any advantage to selecting an old API as the minimum API level? (4 marks)

 Advantage:
o Wider device compatibility.
o More users can install the app on older devices.
 Disadvantage:
o Limited access to modern features.
c) How can you check if an EditText field is empty in Android? (4 marks)

if(textPhoneNum.getText().toString().trim().isEmpty()) {
Toast.makeText(this, "Field cannot be empty",
Toast.LENGTH_SHORT).show();
}

d) Why is it required to store the same image with different resolutions in Android
applications? (4 marks)

 To ensure proper scaling across different screen sizes and resolutions.


 Prevents image distortion or pixelation.

e) What class allows background tasks in Android? (4 marks)

 AsyncTask (deprecated)
 WorkManager (preferred for modern Android development)

Question 05 [20 Marks]

a) Describe the outcomes of Line 1 to Line 4 in the given code.

Line 1:

URL url = new URL("https://192.168.8.100/api/Values");

 Creates a URL object pointing to the specified API endpoint.

Line 2:

HttpURLConnection httpURLConnection = (HttpURLConnection)


url.openConnection();

 Opens a connection to the specified URL for data transfer.

Line 3:

InputStream inputStream = httpURLConnection.getInputStream();

 Retrieves the input stream to read data from the server.

Line 4:

BufferedReader bufferedReader = new BufferedReader(new


InputStreamReader(inputStream));
 Reads the data received from the server using a buffer for efficient reading.

b) Every web service is an API, but Android API is not a web service. Explain why. (6
marks)

 Web Service:
o A web service allows apps to communicate over the internet using protocols
like HTTP.
 Android API:
o An Android API provides functions and classes for local app development
(like working with UI components or file systems).
 Difference:
o Web services work over the network.
o Android API operates within the local app environment.

c) Why does Android use an API that hides source code from developers? (6 marks)

 Reasons:
o Security: Prevents unauthorized access to critical system operations.
o Abstraction: Simplifies development by hiding complex implementations.
o Consistency: Ensures a uniform coding experience across different devices.

You might also like