SubscriptionPlan
public
final
class
SubscriptionPlan
extends Object
implements
Parcelable
| java.lang.Object | |
| ↳ | android.telephony.SubscriptionPlan |
Description of a billing relationship plan between a carrier and a specific subscriber. This information is used to present more useful UI to users, such as explaining how much mobile data they have remaining, and what will happen when they run out.
If specifying network types, the developer must supply at least one plan
that applies to all network types (default), and all additional plans
may not include a particular network type more than once.
This is enforced by SubscriptionManager when setting the plans.
Plan selection will prefer plans that have specific network types defined over plans that apply to all network types.
See also:
Summary
Nested classes | |
|---|---|
class |
SubscriptionPlan.Builder
Builder for a |
Constants | |
|---|---|
long |
BYTES_UNKNOWN
Value indicating a number of bytes is unknown. |
long |
BYTES_UNLIMITED
Value indicating a number of bytes is unlimited. |
int |
LIMIT_BEHAVIOR_BILLED
Indicates that the user will be billed for data usage beyond the limit. |
int |
LIMIT_BEHAVIOR_DISABLED
Indicates that data access is disabled when the data limit is reached. |
int |
LIMIT_BEHAVIOR_THROTTLED
Indicates that data access is throttled to a slower speed when the limit is reached. |
int |
LIMIT_BEHAVIOR_UNKNOWN
Indicates that the behavior for when a data limit is reached is unknown. |
int |
SUBSCRIPTION_STATUS_ACTIVE
The subscription is active. |
int |
SUBSCRIPTION_STATUS_INACTIVE
The subscription is inactive. |
int |
SUBSCRIPTION_STATUS_SUSPENDED
The subscription is suspended. |
int |
SUBSCRIPTION_STATUS_TRIAL
The subscription is in a trial period. |
int |
SUBSCRIPTION_STATUS_UNKNOWN
The subscription status is unknown. |
long |
TIME_UNKNOWN
Value indicating a timestamp is unknown. |
Inherited constants |
|---|
Fields | |
|---|---|
public
static
final
Creator<SubscriptionPlan> |
CREATOR
|
Public methods | |
|---|---|
Iterator<Range<ZonedDateTime>>
|
cycleIterator()
Returns an iterator that provides the data usage billing cycles for this plan, based on its recurrence rule. |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one. |
int
|
getDataLimitBehavior()
Returns the behavior of data access when usage reaches the limit defined by
|
long
|
getDataLimitBytes()
Returns the data limit for the plan. |
long
|
getDataUsageBytes()
Returns a snapshot of the mobile data usage, in bytes, as of the time reported by
|
long
|
getDataUsageTime()
Returns the time at which |
int[]
|
getNetworkTypes()
Returns the network types that this plan applies to. |
ZonedDateTime
|
getPlanEndDate()
Returns the end date of this subscription plan. |
int
|
getSubscriptionStatus()
Returns the status of the subscription plan. |
CharSequence
|
getSummary()
Returns a brief, human-readable summary of the subscription plan. |
CharSequence
|
getTitle()
Returns a user-visible title for this plan. |
int
|
hashCode()
Returns a hash code value for the object. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
|---|---|
Constants
BYTES_UNKNOWN
public static final long BYTES_UNKNOWN
Value indicating a number of bytes is unknown.
This value is used when the carrier has not provided a specific data limit or usage value.
Constant Value: -1 (0xffffffffffffffff)
BYTES_UNLIMITED
public static final long BYTES_UNLIMITED
Value indicating a number of bytes is unlimited.
This value is used when the carrier has not specified a data limit.
Constant Value: 9223372036854775807 (0x7fffffffffffffff)
LIMIT_BEHAVIOR_BILLED
public static final int LIMIT_BEHAVIOR_BILLED
Indicates that the user will be billed for data usage beyond the limit.
When the user exceeds their data limit, they will incur overage charges. Data access continues, but at an additional cost.
Constant Value: 1 (0x00000001)
LIMIT_BEHAVIOR_DISABLED
public static final int LIMIT_BEHAVIOR_DISABLED
Indicates that data access is disabled when the data limit is reached.
Once the user's data usage hits the defined limit, their mobile data connection will be turned off until the next billing cycle begins.
Constant Value: 0 (0x00000000)
LIMIT_BEHAVIOR_THROTTLED
public static final int LIMIT_BEHAVIOR_THROTTLED
Indicates that data access is throttled to a slower speed when the limit is reached.
After the user consumes their high-speed data allowance, the data connection remains active but is reduced to a lower bandwidth for the remainder of the billing cycle.
Constant Value: 2 (0x00000002)
LIMIT_BEHAVIOR_UNKNOWN
public static final int LIMIT_BEHAVIOR_UNKNOWN
Indicates that the behavior for when a data limit is reached is unknown.
This is the default value and should be used when the carrier has not specified what happens when the user's data usage exceeds the limit.
Constant Value: -1 (0xffffffff)
SUBSCRIPTION_STATUS_ACTIVE
public static final int SUBSCRIPTION_STATUS_ACTIVE
The subscription is active.
This indicates that the subscription is in good standing and all services are available to the user.
Constant Value: 1 (0x00000001)
SUBSCRIPTION_STATUS_INACTIVE
public static final int SUBSCRIPTION_STATUS_INACTIVE
The subscription is inactive.
This status means the subscription is not currently in service. This could be because it has been canceled, has expired, or has not yet been activated.
Constant Value: 2 (0x00000002)
SUBSCRIPTION_STATUS_SUSPENDED
public static final int SUBSCRIPTION_STATUS_SUSPENDED
The subscription is suspended.
A suspended subscription has been temporarily disabled. This can occur due to billing issues, a user's request, or a violation of the carrier's terms of service. Services are unavailable, but the subscription can typically be reactivated.
Constant Value: 4 (0x00000004)
SUBSCRIPTION_STATUS_TRIAL
public static final int SUBSCRIPTION_STATUS_TRIAL
The subscription is in a trial period.
This indicates that the user is on a promotional or trial plan, which may have different features or limitations than a standard subscription. After the trial period ends, the status will typically change to active or inactive.
Constant Value: 3 (0x00000003)
SUBSCRIPTION_STATUS_UNKNOWN
public static final int SUBSCRIPTION_STATUS_UNKNOWN
The subscription status is unknown.
This is the default value, used when the carrier is unable to provide the current status of the subscription.
Constant Value: 0 (0x00000000)
TIME_UNKNOWN
public static final long TIME_UNKNOWN
Value indicating a timestamp is unknown.
Constant Value: -1 (0xffffffffffffffff)
Fields
Public methods
cycleIterator
public Iterator<Range<ZonedDateTime>> cycleIterator ()
Returns an iterator that provides the data usage billing cycles for this plan, based on its recurrence rule.
The iterator starts from the cycle that is currently active and walks backwards through time.
Each cycle is represented as a Range of ZonedDateTime objects, indicating the
start and end of that period.
| Returns | |
|---|---|
Iterator<Range<ZonedDateTime>> |
An iterator for the plan's billing cycles. |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int),
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR bit.
| Returns | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or
|
equals
public boolean equals (Object obj)
Indicates whether some other object is "equal to" this one.
The equals method implements an equivalence relation
on non-null object references:
- It is reflexive: for any non-null reference value
x,x.equals(x)should returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| Parameters | |
|---|---|
obj |
Object: This value may be null. |
| Returns | |
|---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
getDataLimitBehavior
public int getDataLimitBehavior ()
Returns the behavior of data access when usage reaches the limit defined by
getDataLimitBytes().
This defines what happens to the user's data connection once they have consumed the amount of data specified in the data limit. For example, the carrier might throttle the connection to a slower speed, disable it entirely, or start billing for overage.
| Returns | |
|---|---|
int |
The data limit behavior, which will be one of LIMIT_BEHAVIOR_UNKNOWN,
LIMIT_BEHAVIOR_DISABLED, LIMIT_BEHAVIOR_BILLED, or
LIMIT_BEHAVIOR_THROTTLED.
Value is one of the following: |
getDataLimitBytes
public long getDataLimitBytes ()
Returns the data limit for the plan.
This is the usage threshold, in bytes, at which data access changes according to
the behavior defined by getDataLimitBehavior(). For example, once data usage
reaches this limit, the connection might be throttled or disabled.
Value is a non-negative number of bytes.
| Returns | |
|---|---|
long |
The data limit in bytes. This may be BYTES_UNKNOWN if the limit is not
available, or BYTES_UNLIMITED if there is no limit.
Value is a non-negative number of bytes. |
getDataUsageBytes
public long getDataUsageBytes ()
Returns a snapshot of the mobile data usage, in bytes, as of the time reported by
getDataUsageTime().
The usage reported here corresponds to the data consumption within the current billing
cycle defined by ERROR(/#getCycleRule()). If the plan specifies different limits for
various network types, this value represents the total usage across all applicable
networks.
Value is a non-negative number of bytes.
| Returns | |
|---|---|
long |
The data usage in bytes, or BYTES_UNKNOWN if unavailable.
Value is a non-negative number of bytes. |
getDataUsageTime
public long getDataUsageTime ()
Returns the time at which getDataUsageBytes() was measured, in milliseconds
since the Unix epoch.
This timestamp indicates how recent the data usage information is. It allows applications
to decide whether the usage value is current enough for their needs.
Value is a non-negative timestamp measured as the number of
milliseconds since 1970-01-01T00:00:00Z.
| Returns | |
|---|---|
long |
The time of the data usage snapshot as a Unix epoch timestamp, or
TIME_UNKNOWN if unavailable.
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
See also:
getNetworkTypes
public int[] getNetworkTypes ()
Returns the network types that this plan applies to.
A "default" plan, which applies to any network type not explicitly covered by another plan, will include all possible network types in the returned array. Each subscription should have at most one default plan.
A RAT-specific plan will return an array containing only the network types it applies to,
for example, TelephonyManager.NETWORK_TYPE_LTE.
| Returns | |
|---|---|
int[] |
A new copy of the array of network types this plan applies to. The values will be
constants from TelephonyManager, such as TelephonyManager.NETWORK_TYPE_LTE.
This value cannot be null.
Value is one of the following:
|
getPlanEndDate
public ZonedDateTime getPlanEndDate ()
Returns the end date of this subscription plan.
This indicates the specific date and time when the plan is no longer valid. For recurring
plans that do not have a defined end, this will be null.
| Returns | |
|---|---|
ZonedDateTime |
The plan's end date as a ZonedDateTime, or null if unavailable. |
getSubscriptionStatus
public int getSubscriptionStatus ()
Returns the status of the subscription plan.
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.
| Returns | |
|---|---|
int |
The subscription status, which is one of the SUBSCRIPTION_STATUS_*
constants, or SUBSCRIPTION_STATUS_UNKNOWN if not available.
Value is one of the following: |
getSummary
public CharSequence getSummary ()
Returns 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.
| Returns | |
|---|---|
CharSequence |
A short, user-friendly summary of the plan, or null if not specified. |
getTitle
public CharSequence getTitle ()
Returns 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.
| Returns | |
|---|---|
CharSequence |
The title of the plan, or null if not specified. |
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap.
The general contract of hashCode is:
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equalsmethod, then calling thehashCodemethod on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
equalsmethod, then calling thehashCodemethod on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
| Returns | |
|---|---|
int |
a hash code value for this object. |
toString
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
dest |
Parcel: The Parcel in which the object should be written.
This value cannot be null. |
flags |
int: Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following:
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-02-13 UTC.