Lesson Plan: Unit - 07
Subject: P15A2AAD - Android Application Development
Topic of Study: Making and Receiving Phone Calls
Grade/Level: Master of Computer Applications
Objective: Making and Receiving Phone Calls
Time Allotment: 55 Minutes
Subject: P15A2AAD - Android Application Development
Topic of Study: Making and Receiving Phone Calls
Grade/Level: Master of Computer Applications
Objective: Making and Receiving Phone Calls
Time Allotment: 55 Minutes
- Making and Receiving Phone Calls
- The difference between dialing and calling:
- You can do this in two ways:
- Use an implicit Intent and ACTION_DIAL to launch the Phone app and display the phone number in the dialer.
- This is the simplest way, with no need to request permission from the user.
- The user can change the phone number before dialing the call.
- The user navigates back to your app using the Back button after the call is completed.
- Use an implicit Intent and ACTION_CALL to make the phone call directly from within your app.
- This action keeps the user within your app, without having to navigate back from the Phone app.
- Your code must ask the user for permission before making the call if the user hasn't already granted permission.
- Your app can monitor the state of the phone call.
- Making Phone Calls:
- Phones are often still used for making and receiving phone calls.
- The Android SDK enables phone numbers to be passed to the dialer in two different ways.
- Way 01: The first way is to launch the dialer with a phone number already entered.
- The user then needs to press the Send button to actually initiate the call.
- This method does not require any specific permissions.
- Way 02:The second way is to actually place the call.
- This method requires the android.permission.CALL_PHONE permission to be added to the application’s AndroidManifest.xml file.
- Android provides Built-in applications for phone calls, in some occasions we may need to make a phone call through our application.
- Also, we can use PhoneStateListener and TelephonyManager classes, in order to monitor the changes in some telephony states on the device.
- Receving Phone Calls:
- An application can register to answer incoming phone calls.
- To enable this within an application, you must implement a broadcast receiver to process intents with the action Intent.ACTION_ANSWER.
- You can use the CallLog.calls class to determine recent call information, such as
- Who called
- When they called
- Whether it was an incoming or outgoing call
- Whether or not anyone answered
- The duration of the call
- Example: