SubscriptionPlan.Builder
public
static
class
SubscriptionPlan.Builder
extends Object
| java.lang.Object | |
| ↳ | android.telephony.SubscriptionPlan.Builder |
Builder for a SubscriptionPlan.
Summary
Public methods | |
|---|---|
SubscriptionPlan
|
build()
|
static
SubscriptionPlan.Builder
|
createNonrecurring(ZonedDateTime start, ZonedDateTime end)
Start defining a |
static
SubscriptionPlan.Builder
|
createNonrecurring(Period duration)
Start defining a template for a non-recurring |
static
SubscriptionPlan.Builder
|
createRecurring(ZonedDateTime start, Period period)
Start defining a |
SubscriptionPlan.Builder
|
resetNetworkTypes()
Reset any network types that were set with |
SubscriptionPlan.Builder
|
setDataLimit(long dataLimitBytes, int dataLimitBehavior)
Set the usage threshold at which data access changes. |
SubscriptionPlan.Builder
|
setDataUsage(long dataUsageBytes, long dataUsageTime)
Set a snapshot of currently known mobile data usage. |
SubscriptionPlan.Builder
|
setDataUsageResetTime(ZonedDateTime dataUsageResetTime)
Sets the time when the data usage allowance will reset. |
SubscriptionPlan.Builder
|
setId(int id)
Sets the unique integer identifier for this subscription plan. |
SubscriptionPlan.Builder
|
setNetworkTypes(int[] networkTypes)
Set the network types this SubscriptionPlan applies to. |
SubscriptionPlan.Builder
|
setStreamingAppMaxDownlinkKbps(long downlinkKbps)
Sets the maximum downstream bitrate for streaming applications on this subscription plan, in Kilobits per second (Kbps) defined in GSMA TS.43 9.1.3. |
SubscriptionPlan.Builder
|
setStreamingAppMaxUplinkKbps(long uplinkKbps)
Sets the maximum upstream bitrate for streaming applications on this subscription plan, in Kilobits per second (Kbps) defined in GSMA TS.43 9.1.3. |
SubscriptionPlan.Builder
|
setSubscriptionStatus(int subscriptionStatus)
Set the subscription status. |
SubscriptionPlan.Builder
|
setSummary(CharSequence summary)
Sets a brief, human-readable summary of the subscription plan. |
SubscriptionPlan.Builder
|
setTitle(CharSequence title)
Sets a user-visible title for this plan. |
SubscriptionPlan.Builder
|
setTypes(int[] types)
Set the types of this subscription plan. |
Inherited methods | |
|---|---|
Public methods
createNonrecurring
public static SubscriptionPlan.Builder createNonrecurring (ZonedDateTime start, ZonedDateTime end)
Start defining a SubscriptionPlan that covers a very specific window of time, and
never automatically recurs.
| Parameters | |
|---|---|
start |
ZonedDateTime: The exact time at which the plan starts. |
end |
ZonedDateTime: The exact time at which the plan ends. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
|
createNonrecurring
public static SubscriptionPlan.Builder createNonrecurring (Period duration)
Start defining a template for a non-recurring SubscriptionPlan with a specific
duration.
This is useful for describing fixed-duration plans that users can enroll in, such as a travel pass or a one-time data package. The actual start and end dates are determined upon enrollment.
Plans created with this builder should be marked with
setSubscriptionStatus(int) and a status of
SubscriptionPlan.SUBSCRIPTION_STATUS_INACTIVE.
| Parameters | |
|---|---|
duration |
Period: The total duration of the plan once activated (e.g., Period.ofDays(15)).
This value cannot be null. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
A Builder instance for a non-recurring plan template.
This value cannot be null. |
createRecurring
public static SubscriptionPlan.Builder createRecurring (ZonedDateTime start, Period period)
Start defining a SubscriptionPlan that starts at a specific time, and
automatically recurs after each specific period of time, repeating indefinitely.
When the given period is set to exactly one month, the plan will always recur on the day
of the month defined by ZonedDateTime.getDayOfMonth(). When a particular month
ends before this day, the plan will recur on the last possible instant of that month.
| Parameters | |
|---|---|
start |
ZonedDateTime: The exact time at which the plan starts. |
period |
Period: The period after which the plan automatically recurs. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
|
resetNetworkTypes
public SubscriptionPlan.Builder resetNetworkTypes ()
Reset any network types that were set with setNetworkTypes(int[]).
This will make the SubscriptionPlan apply to all network types.
| Returns | |
|---|---|
SubscriptionPlan.Builder |
This value cannot be null. |
setDataLimit
public SubscriptionPlan.Builder setDataLimit (long dataLimitBytes, int dataLimitBehavior)
Set the usage threshold at which data access changes.
| Parameters | |
|---|---|
dataLimitBytes |
long: the usage threshold at which data access changes.
Value is a non-negative number of bytes. |
dataLimitBehavior |
int: the behavior of data access when usage reaches the threshold.
Value is one of the following: |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
|
setDataUsage
public SubscriptionPlan.Builder setDataUsage (long dataUsageBytes, long dataUsageTime)
Set a snapshot of currently known mobile data usage.
| Parameters | |
|---|---|
dataUsageBytes |
long: the currently known mobile data usage.
Value is a non-negative number of bytes. |
dataUsageTime |
long: the time at which this snapshot was valid.
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
|
setDataUsageResetTime
public SubscriptionPlan.Builder setDataUsageResetTime (ZonedDateTime dataUsageResetTime)
Sets the time when the data usage allowance will reset.
This is particularly relevant for plans with a daily data allowance, as it specifies the exact moment (e.g., midnight in a specific timezone) when the usage for the next 24-hour will reset. For other types of plans, this may not be applicable.
The value provided for setDataUsage(long, long) should reflect the data consumed
since the last reset time.
| Parameters | |
|---|---|
dataUsageResetTime |
ZonedDateTime: The data usage reset time, or null if this information
is not available or not applicable to the plan. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
This value cannot be null. |
setId
public SubscriptionPlan.Builder setId (int id)
Sets the unique integer identifier for this subscription plan.
This ID is provided by the carrier and can be used to uniquely identify this plan, particularly when interacting with entitlement server for enrolling.
| Parameters | |
|---|---|
id |
int: The unique integer integer identifier for the plan, or SubscriptionPlan.UNSPECIFIED_ID
to clear it. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
The same Builder instance to continue building the plan.
This value cannot be null. |
setNetworkTypes
public SubscriptionPlan.Builder setNetworkTypes (int[] networkTypes)
Set the network types this SubscriptionPlan applies to. By default the plan will apply to all network types. An empty array means this plan applies to no network types.
| Returns | |
|---|---|
SubscriptionPlan.Builder |
This value cannot be null. |
setStreamingAppMaxDownlinkKbps
public SubscriptionPlan.Builder setStreamingAppMaxDownlinkKbps (long downlinkKbps)
Sets the maximum downstream bitrate for streaming applications on this subscription plan, in Kilobits per second (Kbps) defined in GSMA TS.43 9.1.3.
| Parameters | |
|---|---|
downlinkKbps |
long: The maximum downstream bandwidth in Kbps. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
This value cannot be null. |
setStreamingAppMaxUplinkKbps
public SubscriptionPlan.Builder setStreamingAppMaxUplinkKbps (long uplinkKbps)
Sets the maximum upstream bitrate for streaming applications on this subscription plan, in Kilobits per second (Kbps) defined in GSMA TS.43 9.1.3.
| Parameters | |
|---|---|
uplinkKbps |
long: The maximum upstream bitrate in Kbps. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
This value cannot be null. |
setSubscriptionStatus
public SubscriptionPlan.Builder setSubscriptionStatus (int subscriptionStatus)
Set the subscription status.
This indicates the current state of the subscription, such as whether it is active, suspended, or in a trial period. This status provides context on the plan's availability and can be used to inform the user about their subscription's lifecycle.
| Parameters | |
|---|---|
subscriptionStatus |
int: the current subscription status.
Value is one of the following: |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
This value cannot be null. |
setSummary
public SubscriptionPlan.Builder setSummary (CharSequence summary)
Sets a brief, human-readable summary of the subscription plan.
This could include details about the plan's features, such as "10GB of high-speed data" or "Unlimited talk and text". This summary is intended for display to the user.
| Parameters | |
|---|---|
summary |
CharSequence: A short, user-friendly summary of the plan, or null to clear it. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
|
setTitle
public SubscriptionPlan.Builder setTitle (CharSequence title)
Sets a user-visible title for this plan.
This title is provided by the carrier to identify the subscription plan, for example, "Unlimited+" or "Family plan". It is intended for display to the user.
| Parameters | |
|---|---|
title |
CharSequence: The title of the plan.
This value may be null. |
| Returns | |
|---|---|
SubscriptionPlan.Builder |
The same Builder instance to continue building the plan. |
setTypes
public SubscriptionPlan.Builder setTypes (int[] types)
Set the types of this subscription plan. A plan can have multiple types, and this method will return all that are applicable. For example, a plan could be both a cellular plan and a postpaid plan.
| Parameters | |
|---|---|
types |
int: This value cannot be null.
Value is one of the following:
|
| Returns | |
|---|---|
SubscriptionPlan.Builder |
An array containing the applicable PLAN_TYPE_ constants.
This value cannot be null. |
See also:
SubscriptionPlan.PLAN_TYPE_CELLULARSubscriptionPlan.PLAN_TYPE_SATELLITESubscriptionPlan.PLAN_TYPE_IOTSubscriptionPlan.PLAN_TYPE_POSTPAIDSubscriptionPlan.PLAN_TYPE_PREPAIDSubscriptionPlan.PLAN_TYPE_DATA_ONLYSubscriptionPlan.PLAN_TYPE_FAMILYSubscriptionPlan.PLAN_TYPE_BUSINESSSubscriptionPlan.PLAN_TYPE_ROAMINGSubscriptionPlan.PLAN_TYPE_TETHERING