Android Programming: Activities and Services, Exercises of Information Technology

This chapter focuses on activities and services in android programming. Topics include writing the correct syntax for extending the thread class and implementing a run method, understanding different service lifecycle methods, registering a service in the manifest file, creating an alert dialog, and differentiating handler from asynctask.

Typology: Exercises

2021/2022

Uploaded on 12/04/2022

saikichufo
saikichufo 🇵🇭

2 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 4: Activities
Name: June Kenneth Ivan T. Castillo Program/Block: BSInfoTech3A
1. Write the correct syntax in extending the Thread class and implement a run method.
2. List the different service lifecycle methods.
onCreate ()
onStartCommand (Intent, int, int)
onDestroy ()
onBind (Intent)
onStartCommand ()
START_STICKY
START_NOT_STICKY
START_REDELIVER_INTENT
3. Write the correct syntax in registering a service in the android manifest life.
4. Create an alert dialog by calling the create() method of the builder class.
5. Create a NotificationCompat.Builder named sampleBuilder.
6. Differentiate Handler from AsyncTask.
Handler is background threads that provide you to communicate with UI. It handles
and schedules messages and runnables sent from background threads to the app
main thread. Whereas AsyncTask provides a simple method to handle background
threads in order to update the UI without blocking it by time consuming operations.s
public class MyThread extends Thread {
public void run () {
//input the thread code
}
}
MyThread thread = new MyThread
thread.start();
<service android:name = “.nameOfService”/>
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
NotificationCompat.Builder sampleBuilder = new
NotificationCompat.Builder(this);

Partial preview of the text

Download Android Programming: Activities and Services and more Exercises Information Technology in PDF only on Docsity!

Chapter 4: Activities Name: June Kenneth Ivan T. Castillo Program/Block : BSInfoTech3A

  1. Write the correct syntax in extending the Thread class and implement a run method.
  2. List the different service lifecycle methods.  onCreate ()  onStartCommand (Intent, int, int)  onDestroy ()  onBind (Intent)  onStartCommand () START_STICKY START_NOT_STICKY START_REDELIVER_INTENT
  3. Write the correct syntax in registering a service in the android manifest life.
  4. Create an alert dialog by calling the create() method of the builder class.
  5. Create a NotificationCompat.Builder named sampleBuilder.
  6. Differentiate Handler from AsyncTask. Handler is background threads that provide you to communicate with UI. It handles and schedules messages and runnables sent from background threads to the app main thread. Whereas AsyncTask provides a simple method to handle background threads in order to update the UI without blocking it by time consuming operations.s public class MyThread extends Thread { public void run () { //input the thread code } } MyThread thread = new MyThread thread.start(); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); NotificationCompat.Builder sampleBuilder = new NotificationCompat.Builder(this);