본문 바로가기
Android

android-developer-phone-sms-course.pdf

by OKOK 2021. 6. 24.

https://developer.android.com/courses

 

학습 과정  |  Android Developers

자신에게 적합한 학습 옵션을 찾아보세요.

developer.android.com

 

Android runtime : Easch app runs in its own process with its own instance of the Android Runtime.

 

android-developer-phone-sms-course.pdf

In Android Phone Calls, students learn how to use the telephony features in Android. In the practical, they create an app that launches the Phone app with a phone number to make a call, and another app that checks for needed permissions and services, and then lets the user make a phone call from within the app.

 

1: Phone Calls

 

The difference between dialing and calling

Use an implicit Intent and ACTION_DIAL to launch the Phone app and display the phone number in the dialer.

 

Formatting a phone number

To use an intent to launch the Phone app with a phone number to dial, you app needs to prepare a Uniform Resource Identifier for the phone number.

 

Using an intent with the phone number to dial

To use an intent to launch the Phone app, use a button to let the user start the call. When the user taps the button, its click handler initialtes the call. For example, a simple layout could provide an ImageButton like the phone icon in the figure below. 

 

The Phone app pens with the number to be dialed. The user can change the number and initiate the call. The Phone app then makes the call. In the dialNumber() method, use an implicity intent with the intent action ACTION_DIAL to pass the phone number to the Phone app as a URI.

public void dialNumbe(){

}

 

Sending an intent with a phone number to dial

 

Making a call from within your app

To make a phone call directly from your app, do the following:

1. Add permissions that enable amking a call and reading the phone activity.

2. Check to see if telephony is enabled; if not, disable the phone feature.

3. Check to see if the user continues to grant permission, or request permission if needed.

4. Extend PhoneStateListner, and register the listener using the TelephonyManager class.

5. Use an implicity intent with ACTION_CALL to make the phone call.

 

Adding permissions to the manifest

Access to telephony information is permission-protectd. In order to make a call, your app needs the CALL_PHONE permission. In addition, in order to monitor the phone state, your app needs the READ_PHONE_STATE permission. Both must be declared in the apps's AndroidManifest.xml file. 

 

Checking and requesting user permission

Begginning in Android 6.0, users grant permissions to apps while the app is running, not when they install app. This approach streamlines the app install process, since the user does not need to grant permissions when they install or update the app.

 

Using emulators to test phone calls

 

 

Related practival

 

 

Learn more

'Android' 카테고리의 다른 글

adb 사용 예  (0) 2021.07.09
eSIM 구현  (0) 2021.06.25
SL4A(Scripting Layer for Android) (2)  (0) 2021.06.23
SL4A(Scripting Layer for Android) (1)  (0) 2021.06.23
안드로이드 프로그래밍 Next Step 5장 액티비티  (0) 2021.06.22

댓글