전화 리디렉션
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 10 이상을 실행하는 기기는 통화 인텐트를 관리하는 방식과 다르게
Android 9 이하를 실행하는 기기 Android 10 이상에서는
ACTION_NEW_OUTGOING_CALL
드림
브로드캐스트가 지원 중단되고
CallRedirectionService
API에 액세스할 수 있습니다. CallRedirectionService
는 다음 작업에 사용할 인터페이스를 제공합니다.
Android 플랫폼에서 거는 발신 전화를 수정할 수 없습니다. 예: 서드 파티
앱에서 통화를 취소하고 VoIP를 통해 다시 라우팅할 수 있습니다.
Kotlin
class RedirectionService : CallRedirectionService() {
override fun onPlaceCall(
handle: Uri,
initialPhoneAccount: PhoneAccountHandle,
allowInteractiveResponse: Boolean
) {
// Determine if the call should proceed, be redirected, or cancelled.
val callShouldProceed = true
val callShouldRedirect = false
when {
callShouldProceed -> {
placeCallUnmodified()
}
callShouldRedirect -> {
// Update the URI to point to a different phone number or modify the
// PhoneAccountHandle and redirect.
redirectCall(handle, initialPhoneAccount, true)
}
else -> {
cancelCall()
}
}
}
}
자바
class RedirectionService extends CallRedirectionService {
@Override
public void onPlaceCall(
@NonNull Uri handle,
@NonNull PhoneAccountHandle initialPhoneAccount,
boolean allowInteractiveResponse
) {
// Determine if the call should proceed, be redirected, or cancelled.
// Your app should implement this logic to determine the redirection.
boolean callShouldProceed = true;
boolean callShouldRedirect = false;
if (callShouldProceed) {
placeCallUnmodified();
} else if (callShouldRedirect) {
// Update the URI to point to a different phone number or modify the
// PhoneAccountHandle and redirect.
redirectCall(handle, initialPhoneAccount, true);
} else {
cancelCall();
}
}
}
시스템에서 시작할 수 있도록 매니페스트에 이 서비스를 등록해야 합니다.
있습니다.
<service
android:name=".RedirectionService"
android:permission="android.permission.BIND_CALL_REDIRECTION_SERVICE">
<intent-filter>
<action android:name="android.telecom.CallRedirectionService"/>
</intent-filter>
</service>
리디렉션 서비스를 사용하려면 앱에서 통화 리디렉션 역할을 요청해야 합니다.
RoleManager
에서 가져옴 요청 사항
사용자가 앱에서 통화 리디렉션을 처리하도록 할 수 있습니다. 앱이
에 이 역할이 부여되지 않으면 리디렉션 서비스가 사용되지 않습니다.
사용자가 앱을 실행할 때 앱에 이 역할이 있는지 확인하여
필요에 따라 요청할 수 있습니다 RoleManager
에서 만든 인텐트를 실행합니다.
따라서
onActivityResult()
함수를 사용하여 사용자의 선택을 처리합니다.
Kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Tell the system that you want your app to handle call redirects. This
// is done by using the RoleManager to register your app to handle redirects.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
val roleManager = getSystemService(Context.ROLE_SERVICE) as RoleManager
// Check if the app needs to register call redirection role.
val shouldRequestRole = roleManager.isRoleAvailable(RoleManager.ROLE_CALL_REDIRECTION) &&
!roleManager.isRoleHeld(RoleManager.ROLE_CALL_REDIRECTION)
if (shouldRequestRole) {
val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_REDIRECTION)
startActivityForResult(intent, REDIRECT_ROLE_REQUEST_CODE)
}
}
}
companion object {
private const val REDIRECT_ROLE_REQUEST_CODE = 1
}
}
Java
class MainActivity extends AppCompatActivity {
private static final int REDIRECT_ROLE_REQUEST_CODE = 0;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Tell the system that you want your app to handle call redirects. This
// is done by using the RoleManager to register your app to handle redirects.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
RoleManager roleManager = (RoleManager) getSystemService(Context.ROLE_SERVICE);
// Check if the app needs to register call redirection role.
boolean shouldRequestRole = roleManager.isRoleAvailable(RoleManager.ROLE_CALL_REDIRECTION) &&
!roleManager.isRoleHeld(RoleManager.ROLE_CALL_REDIRECTION);
if (shouldRequestRole) {
Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_REDIRECTION);
startActivityForResult(intent, REDIRECT_ROLE_REQUEST_CODE);
}
}
}
}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Redirect a call\n\nDevices that run Android 10 or higher manage call intents differently than\ndevices that run Android 9 or lower. On Android 10 and higher, the\n[`ACTION_NEW_OUTGOING_CALL`](/reference/android/content/Intent#ACTION_NEW_OUTGOING_CALL)\nbroadcast is deprecated and replaced with the\n[`CallRedirectionService`](/reference/android/telecom/CallRedirectionService)\nAPI. The `CallRedirectionService` provides interfaces for you to use to\nmodify outgoing calls made by the Android platform. For example, third-party\napps might cancel calls and reroute them over VoIP. \n\n### Kotlin\n\n```kotlin\nclass RedirectionService : CallRedirectionService() {\n override fun onPlaceCall(\n handle: Uri,\n initialPhoneAccount: PhoneAccountHandle,\n allowInteractiveResponse: Boolean\n ) {\n // Determine if the call should proceed, be redirected, or cancelled.\n val callShouldProceed = true\n val callShouldRedirect = false\n when {\n callShouldProceed -\u003e {\n placeCallUnmodified()\n }\n callShouldRedirect -\u003e {\n // Update the URI to point to a different phone number or modify the\n // PhoneAccountHandle and redirect.\n redirectCall(handle, initialPhoneAccount, true)\n }\n else -\u003e {\n cancelCall()\n }\n }\n }\n}\n```\n\n### Java\n\n```java\nclass RedirectionService extends CallRedirectionService {\n @Override\n public void onPlaceCall(\n @NonNull Uri handle,\n @NonNull PhoneAccountHandle initialPhoneAccount,\n boolean allowInteractiveResponse\n ) {\n // Determine if the call should proceed, be redirected, or cancelled.\n // Your app should implement this logic to determine the redirection.\n boolean callShouldProceed = true;\n boolean callShouldRedirect = false;\n if (callShouldProceed) {\n placeCallUnmodified();\n } else if (callShouldRedirect) {\n // Update the URI to point to a different phone number or modify the\n // PhoneAccountHandle and redirect.\n redirectCall(handle, initialPhoneAccount, true);\n } else {\n cancelCall();\n }\n }\n}\n```\n\nYou must register this service in the manifest so the system can start it\ncorrectly. \n\n \u003cservice\n android:name=\".RedirectionService\"\n android:permission=\"android.permission.BIND_CALL_REDIRECTION_SERVICE\"\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"android.telecom.CallRedirectionService\"/\u003e\n \u003c/intent-filter\u003e\n \u003c/service\u003e\n\nTo use a redirection service, your app must request the call redirection role\nfrom the [`RoleManager`](/reference/android/app/role/RoleManager). This will ask\nthe user if they want to allow your app to handle call redirects. If your app\nisn't granted this role, your redirection service isn't used.\n\nYou should check if your app has this role when the user launches your app so\nyou can request it as needed. You launch an intent created by the `RoleManager`,\nso ensure you override the\n[`onActivityResult()`](/reference/android/app/Activity#onActivityResult(int,%20int,%20android.content.Intent))\nfunction to handle the user's selection. \n\n### Kotlin\n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n\n // Tell the system that you want your app to handle call redirects. This\n // is done by using the RoleManager to register your app to handle redirects.\n if (android.os.Build.VERSION.SDK_INT \u003e= android.os.Build.VERSION_CODES.Q) {\n val roleManager = getSystemService(Context.ROLE_SERVICE) as RoleManager\n // Check if the app needs to register call redirection role.\n val shouldRequestRole = roleManager.isRoleAvailable(RoleManager.ROLE_CALL_REDIRECTION) &&\n !roleManager.isRoleHeld(RoleManager.ROLE_CALL_REDIRECTION)\n if (shouldRequestRole) {\n val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_REDIRECTION)\n startActivityForResult(intent, REDIRECT_ROLE_REQUEST_CODE)\n }\n }\n }\n\n companion object {\n private const val REDIRECT_ROLE_REQUEST_CODE = 1\n }\n}\n```\n\n### Java\n\n```java\nclass MainActivity extends AppCompatActivity {\n private static final int REDIRECT_ROLE_REQUEST_CODE = 0;\n\n @Override\n protected void onCreate(@Nullable Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n\n // Tell the system that you want your app to handle call redirects. This\n // is done by using the RoleManager to register your app to handle redirects.\n if (android.os.Build.VERSION.SDK_INT \u003e= android.os.Build.VERSION_CODES.Q) {\n RoleManager roleManager = (RoleManager) getSystemService(Context.ROLE_SERVICE);\n // Check if the app needs to register call redirection role.\n boolean shouldRequestRole = roleManager.isRoleAvailable(RoleManager.ROLE_CALL_REDIRECTION) &&\n !roleManager.isRoleHeld(RoleManager.ROLE_CALL_REDIRECTION);\n if (shouldRequestRole) {\n Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_REDIRECTION);\n startActivityForResult(intent, REDIRECT_ROLE_REQUEST_CODE);\n }\n }\n }\n}\n```"]]