Package com.unitech.api.telephony
Class TelephonyCtrl
java.lang.Object
com.unitech.api.telephony.TelephonyCtrl
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBundleDeletes an eSIM subscription by name of ICCID or Display Name.BundledownloadESimSubscription(String activateCode, boolean switchAfterDownload) Downloads an eSIM subscription.BundledownloadESimSubscriptionWithNickName(String activateCode, String nickName, boolean switchAfterDownload) Downloads an eSIM subscription and change nickname.BundlegetEID()Retrieves the eSIM ID.BundleRetrieves the network data usage for the last 24 hours.BundlegetNetworkDataUsageWithRange(long timeRangeSeconds) Retrieves the network data usage from now to the past N second(s) range.BundleRetrieves the Subscription information.BundleChecks if a SIM card exists.BundleswitchESimByName(String name) Switches to the eSIM with the specified display name or ICCID.BundleupdateDisplayNameByIccid(String iccid, String displayName)
-
Field Details
-
BUNDLE_ERROR_CODE
- See Also:
-
BUNDLE_ERROR_MSG
- See Also:
-
RESULT_CODE_ERROR
public static final int RESULT_CODE_ERROR- See Also:
-
RESULT_CODE_SUCCESS
public static final int RESULT_CODE_SUCCESS- See Also:
-
-
Constructor Details
-
TelephonyCtrl
public TelephonyCtrl(Context context)
-
-
Method Details
-
isSimCardExist
public Bundle isSimCardExist()Checks if a SIM card exists.- Returns:
- A
Bundlecontaining the following:int errorCode- The error code (1 for error, 0 for success)String errorMsg- The error message, if anyboolean isSimCardExist- Whether a SIM card exists (default isfalseif not present)
int errorCode = bundle.getInt("errorCode"); String errorMsg = bundle.getString("errorMsg"); boolean isSimCardExist = bundle.getBoolean("isSimCardExist", false);
-
getNetworkDataUsageWithRange
public Bundle getNetworkDataUsageWithRange(long timeRangeSeconds) Retrieves the network data usage from now to the past N second(s) range.- Parameters:
timeRangeSeconds- the past second(s) from now- Returns:
- A
Bundlecontaining the following:int errorCode- error code (1 for error, 0 for success)String errorMsg- error messageArrayList<NetworkDataUsage> networkDataUsages- network data usage list, obtained viaNetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage"))
"0"- No data exists"0 B"- Zero bytes transferred for specific Rx or Tx"X B"- X bytes transferred for specific Rx or Tx (whereBrepresents bytes)
- B - Bytes
- K - Kilobytes (KB)
- M - Megabytes (MB)
- G - Gigabytes (GB)
- T - Terabytes (TB)
- P - Petabytes (PB)
- E - Exabytes (EB)
Bundle bundle = getNetworkDataUsage(); // Retrieve the error code and message int errorCode = bundle.getInt("errorCode"); String errorMsg = bundle.getString("errorMsg"); // Handle error if (errorCode == 1) { Log.d("NetworkDataUsage", "Error: " + errorMsg); } else { // Convert the network data usage list ArrayList<NetworkDataUsage> networkDataUsages = NetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage")); // Process each usage data for (NetworkDataUsage usage : networkDataUsages) { Log.d("NetworkDataUsage", "Mobile Rx: " + usage.getMobileRx()); Log.d("NetworkDataUsage", "Mobile Tx: " + usage.getMobileTx()); Log.d("NetworkDataUsage", "WiFi Rx: " + usage.getWifiRx()); Log.d("NetworkDataUsage", "WiFi Tx: " + usage.getWifiTx()); } }
-
getNetworkDataUsage
public Bundle getNetworkDataUsage()Retrieves the network data usage for the last 24 hours.- Returns:
- A
Bundlecontaining the following:int errorCode- error code (1 for error, 0 for success)String errorMsg- error messageArrayList<NetworkDataUsage> networkDataUsages- network data usage list, obtained viaNetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage"))
"0"- No data exists"0 B"- Zero bytes transferred for specific Rx or Tx"X B"- X bytes transferred for specific Rx or Tx (whereBrepresents bytes)
- B - Bytes
- K - Kilobytes (KB)
- M - Megabytes (MB)
- G - Gigabytes (GB)
- T - Terabytes (TB)
- P - Petabytes (PB)
- E - Exabytes (EB)
Bundle bundle = getNetworkDataUsage(); // Retrieve the error code and message int errorCode = bundle.getInt("errorCode"); String errorMsg = bundle.getString("errorMsg"); // Handle error if (errorCode == 1) { Log.d("NetworkDataUsage", "Error: " + errorMsg); } else { // Convert the network data usage list ArrayList<NetworkDataUsage> networkDataUsages = NetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage")); // Process each usage data for (NetworkDataUsage usage : networkDataUsages) { Log.d("NetworkDataUsage", "Mobile Rx: " + usage.getMobileRx()); Log.d("NetworkDataUsage", "Mobile Tx: " + usage.getMobileTx()); Log.d("NetworkDataUsage", "WiFi Rx: " + usage.getWifiRx()); Log.d("NetworkDataUsage", "WiFi Tx: " + usage.getWifiTx()); } }
-
downloadESimSubscription
Downloads an eSIM subscription.- Parameters:
activateCode- The activation codeswitchAfterDownload- Whether to switch to the downloaded eSIM subscription after download- Returns:
- A bundle containing the error code and message
int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
String errorMsg = bundle.getString("errorMsg");
-
downloadESimSubscriptionWithNickName
public Bundle downloadESimSubscriptionWithNickName(String activateCode, String nickName, boolean switchAfterDownload) Downloads an eSIM subscription and change nickname.- Parameters:
activateCode- The activation codenickName- The nickname of the eSIM subscriptionswitchAfterDownload- Whether to switch to the downloaded eSIM subscription after download- Returns:
- A bundle containing the error code and message
int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
String errorMsg = bundle.getString("errorMsg");
*
-
deleteESimSubscriptionByName
Deletes an eSIM subscription by name of ICCID or Display Name.- Parameters:
name- The display name of the eSIM to switch to- Returns:
- A bundle containing the error code and message
int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
String errorMsg = bundle.getString("errorMsg");
-
switchESimByName
Switches to the eSIM with the specified display name or ICCID.- Parameters:
name- The display name of the eSIM to switch to- Returns:
- A bundle containing the error code and message
int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
String errorMsg = bundle.getString("errorMsg");
-
getEID
public Bundle getEID()Retrieves the eSIM ID.- Returns:
- A bundle containing the error code and message
int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
String errorMsg = bundle.getString("errorMsg");
String EID = bundle.getString("EID");
-
getSubscriptionInfo
public Bundle getSubscriptionInfo()Retrieves the Subscription information.- Returns:
- A bundle containing the error code and message
int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
String errorMsg = bundle.getString("errorMsg");
using keySet() to retrieve what keys are included in this bundle
-
updateDisplayNameByIccid
-