1/3

Android Assignment

BroadcastReceiver

Please conduct the following tasks alone. For implementation details you can refer to the lecture slides or the Android developer website. Please do not hesitate to ask me or the tutor if you have any questions. Under „Tip“ you can find some hints for the task. The „Checklist“ specifies what should happen when your implementation is correct.

2/3

Tasks

  1. Using a BroadcastReceiver to update the User Interface
  2. Receiving System Broadcasts
3/3

1. Using a BroadcastReceiver to update the User Interface

Based on your application from the Service assignment, develop an application that uses a local broadcast to notify an Activity when the Service is finished. Implement a BroadcastReceiver to receive the broadcast event from the Service and to change a text of the TextView that is shown in the corresponding Activity.

Tip

Use the LocalBroadcastManager class to send the broadcast and to register your BroadcastReceiver.

Checklist
TextView shows a new message after X seconds when pressing the button

2. Receiving System Broadcasts

Develop an app that listens to incoming calls and shows a toast message when the event occurs. To test the app open the DDMS perspective and in the emulator tap under „Telephony Action“ you can simulate incoming calls. Tip Implement a class that derives from BroadcastReceiver and shows a toast using Toast.makeText(). Register the BroadcastReceiver in your AndroidManifest using the tag <receiver …> using the intent filter action „android.intent.action.PHONE_STATE".

Checklist
Toast shows when incoming call event occurs