ContextmContext;NetworkmNetwork;publicvoidrequestPremiumCapabilityNetwork(@NetCapabilityintcapability){ConnectvityManagercm=mContext.getSystemService(ConnectivityManager.class);NetworkRequestrequest=NetworkRequest.Builder().addCapability(capability).build();cm.requestNetwork(request,newNetworkCallback(){@OverridepublicvoidonAvailable(Networknetwork){log("Premium capability %d network is available.",capability);mNetwork=network;}@OverridepublicvoidonLost(Networknetwork){log("Premium capability %d network is not available.",capability);mNetwork=null;}});}
NetworkRequest 객체를 빌드할 때 추가하는 기능은 TelephonyManager API에 전달하는 기능과 다릅니다.
다음 표는 TelephonyManager 클래스의 상수를 NetworkCapabilities의 상응하는 상수에 매핑합니다.
ContextmContext;publicbooleanisPremiumCapabilityAvailableForPurchase(@PremiumCapabilityintcapability){TelephonyManagertm=mContext.getSystemService(TelephonyManager.class);booleanisAvailable=tm.isPremiumCapabilityAvailableForPurchase(capability);log("Premium capability %d %s available to purchase.",capability,isAvailable?"is":"is not");returnisAvailable;}
4단계: 업셀링 알림 흐름 시작
프리미엄 기능을 사용할 수 있는지 확인한 후 앱은 purchasePremiumCapability()를 호출하여 업셀링 알림 흐름을 시작해야 합니다. 사용자가 지정된 기능을 아직 구매하지 않았고 모든 기본 조건이 충족되면 플랫폼은 사용자에게 이동통신사에서 성능 향상 옵션을 사용할 수 있다는 알림을 표시합니다. 사용자가 알림을 탭하면 플랫폼은 구매 프로세스를 계속할 수 있도록 이동통신사의 WebView를 엽니다.
구매 요청이 실패하면 앱에서 기본 네트워크를 대신 사용할 수 있습니다.
프리미엄 슬라이스 요청을 처리할 수 없는 경우 자동 대체 동작이 없습니다.
슬라이싱 업셀을 위한 UX 흐름
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 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,["# Use network slicing\n\n5G network slicing gives carriers the ability to provide network performance\nboosts for specific use cases. This guide explains how an app can use the\nnetwork slicing feature.\n\nThis guide also covers how to trigger the [network slicing upsell UX\nflow](#ux-flow) in cases where a purchase is required before the app can\naccess the premium connection.\n\n### Step 1: Declare premium capability intents\n\nIn order for your app's request for a premium slicing capability to be honored,\nyour app must declare its intent to request that capability in the app manifest.\nOtherwise, the network request fails throwing a `SecurityException`.\n\nTo do this, your app must declare the\n[`PackageManager.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES`](/reference/android/content/pm/PackageManager#PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES)\nproperty in the `AndroidManifest.xml` file and include a corresponding XML\nresource file.\n\nA capability declaration in the manifest file looks like this: \n\n \u003cproperty android:name=\"android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES\"\n android:resource=\"@xml/network_capabilities\" /\u003e\n\nThe corresponding `network_capabilities.xml` resource file looks like this: \n\n \u003cnetwork-capabilities-declaration\u003e xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n \u003cuses-network-capability android:name=\"NET_CAPABILITY_PRIORITIZE_LATENCY\"/\u003e\n \u003c/network-capabilities-declaration\u003e\n\n| **Note:** The only premium capability supported in Android 14 is [`NET_CAPABILITY_PRIORITIZE_LATENCY`](/reference/android/net/NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_LATENCY).\n\n### Step 2: Verify if the premium capability is available\n\nCall the\n[`requestNetwork()`](/reference/android/net/ConnectivityManager#requestNetwork(android.net.NetworkRequest,%20android.net.ConnectivityManager.NetworkCallback))\nAPI method to determine whether the premium capability is available. \n\n Context mContext;\n Network mNetwork;\n\n public void requestPremiumCapabilityNetwork(@NetCapability int capability) {\n ConnectvityManager cm = mContext.getSystemService(ConnectivityManager.class);\n NetworkRequest request = NetworkRequest.Builder()\n .addCapability(capability)\n .build();\n cm.requestNetwork(request, new NetworkCallback() {\n @Override\n public void onAvailable(Network network) {\n log(\"Premium capability %d network is available.\", capability);\n mNetwork = network;\n }\n\n @Override\n public void onLost(Network network) {\n log(\"Premium capability %d network is not available.\", capability);\n mNetwork = null;\n }\n });\n }\n\nWhen you build a `NetworkRequest` object, the capability that you add is **not**\nthe same capability that you pass to the `TelephonyManager` APIs.\nThe following table maps the constants from the `TelephonyManager` class to the\ncorresponding constants in `NetworkCapabilities`.\n\n| `TelephonyManager` constant | `NetworkCapabilities` constant |\n|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| [`PREMIUM_CAPABILITY_PRIORITIZE_LATENCY`](/reference/android/telephony/TelephonyManager#PREMIUM_CAPABILITY_PRIORITIZE_LATENCY) | [`NET_CAPABILITY_PRIORITIZE_LATENCY`](/reference/android/net/NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_LATENCY) |\n\n### Step 3: If the premium capability is not available, check availability to purchase\n\n| **Note:** The network slicing upsell feature is only available in Android 14 and higher for apps that have the [`READ_BASIC_PHONE_STATE`](/reference/android/Manifest.permission#READ_BASIC_PHONE_STATE) permission.\n\nCall the [`isPremiumCapabilityAvailableForPurchase()`](/reference/android/telephony/TelephonyManager#isPremiumCapabilityAvailableForPurchase(int))\nAPI method to determine whether the selected premium capability is available.\nThis method returns `true` if the capability is available for purchase from the\ncarrier using the upsell notification workflow. \n\n Context mContext;\n\n public boolean isPremiumCapabilityAvailableForPurchase(@PremiumCapability int capability) {\n TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);\n boolean isAvailable = tm.isPremiumCapabilityAvailableForPurchase(capability);\n log(\"Premium capability %d %s available to purchase.\",\n capability,\n isAvailable ? \"is\" : \"is not\");\n return isAvailable;\n }\n\n### Step 4: Initiate the upsell notification flow\n\nAfter confirming that the premium capability is available, your app should call\n[`purchasePremiumCapability()`](/reference/android/telephony/TelephonyManager#purchasePremiumCapability(int,%20java.util.concurrent.Executor,%20java.util.function.Consumer%3Cjava.lang.Integer%3E))\nto initiate the upsell notification flow. If the user has not already purchased\nthe specified capability and all preconditions are satisfied, then the platform\nshows the user a notification to let them know that performance boost options\nmight be available from their carrier. If the user taps the notification, the\nplatform opens the carrier's webview so that the purchase process can continue. \n\n Context mContext;\n\n public void purchasePremiumCapability(@PremiumCapability int capability) {\n TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);\n tm.purchasePremiumCapability(capability, Runnable::run, new Consumer\u003cInteger\u003e() {\n @Override\n public void accept(Integer result) {\n log(\"Purchase premium capability %d result: %d\", capability, result);\n int purchaseResult = result;\n }\n });\n }\n\nThe `parameter` callback passed to `purchasePremiumCapability()` returns a\nresult code for the purchase request.\n\nThe result codes\n[`PURCHASE_PREMIUM_CAPABILITY_RESULT_SUCCESS`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_SUCCESS)\nand\n[`PURCHASE_PREMIUM_CAPABILITY_RESULT_ALREADY_PURCHASED`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_ALREADY_PURCHASED)\nrepresent successful results where your app may proceed to requesting the\nselected premium capability.\n\nThe result codes in the following list represent failed purchase requests. See\nthe API reference to learn more about them.\n\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_ALREADY_IN_PROGRESS`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_ALREADY_IN_PROGRESS)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_CARRIER_DISABLED`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_CARRIER_DISABLED)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_CARRIER_ERROR`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_CARRIER_ERROR)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_ENTITLEMENT_CHECK_FAILED`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_ENTITLEMENT_CHECK_FAILED)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_FEATURE_NOT_SUPPORTED`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_FEATURE_NOT_SUPPORTED)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_NETWORK_NOT_AVAILABLE`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_NETWORK_NOT_AVAILABLE)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_NOT_DEFAULT_DATA_SUBSCRIPTION`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_NOT_DEFAULT_DATA_SUBSCRIPTION)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_NOT_FOREGROUND`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_NOT_FOREGROUND)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_PENDING_NETWORK_SETUP`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_PENDING_NETWORK_SETUP)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_REQUEST_FAILED`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_REQUEST_FAILED)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_THROTTLED`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_THROTTLED)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_TIMEOUT`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_TIMEOUT)\n- [`PURCHASE_PREMIUM_CAPABILITY_RESULT_USER_CANCELED`](/reference/android/telephony/TelephonyManager#PURCHASE_PREMIUM_CAPABILITY_RESULT_USER_CANCELED)\n\nIf the purchase request fails, your app may use the default network instead.\nThere is no automatic fallback behavior if the premium slice request cannot be\nfulfilled.\n\n### UX flow for slicing upsell"]]