Phone API¶
Control phone calls and retrieve phone information.
Phone State Tracking¶
startTrackingPhoneState()¶
Start tracking phone state changes. Generates 'phone' events.
readPhoneState()¶
Read the current phone state.
Returns: Bundle with phone state and incoming number
stopTrackingPhoneState()¶
Stop tracking phone state.
Making Calls¶
phoneCall()¶
Call a contact/phone number by URI.
Parameters:
- uri (str): Contact URI or phone number URI
phoneCallNumber()¶
Call a phone number directly.
Parameters:
- phone_number (str): Phone number to call
phoneDial()¶
Dial a number (opens dialer without calling).
Parameters:
- uri (str): Contact URI or phone number URI
phoneDialNumber()¶
Dial a phone number (opens dialer without calling).
Parameters:
- phone_number (str): Phone number
Cell Location¶
getCellLocation()¶
Get the current cell location.
Returns: JSONObject with cell location data
getAllCellsLocation()¶
Get all cell locations (for dual SIM devices).
Returns: JSONArray of cell locations
Network Information¶
getNetworkOperator()¶
Get the MCC+MNC of the current operator.
Returns: String (e.g., '310260')
getNetworkOperatorName()¶
Get the name of the current operator.
Returns: String (e.g., 'T-Mobile')
getNetworkType()¶
Get the current network type.
Returns: String describing radio technology (e.g., 'LTE', 'UMTS', 'GSM')
getPhoneType()¶
Get the phone type.
Returns: String (e.g., 'GSM', 'CDMA', 'SIP')
SIM Information¶
getSimCountryIso()¶
Get the ISO country code for the SIM.
Returns: String (e.g., 'us')
getSimOperator()¶
Get the MCC+MNC of the SIM operator.
Returns: String (e.g., '310260')
getSimOperatorName()¶
Get the SIM operator name.
Returns: String (e.g., 'T-Mobile')
getSimSerialNumber()¶
Get the SIM serial number.
Returns: String SIM serial number
getSimState()¶
Get the SIM card state.
Returns: String describing SIM state
getSubscriberId()¶
Get the subscriber ID.
Returns: String subscriber ID
Voice Mail¶
getVoiceMailAlphaTag()¶
Get the voice mail alpha tag.
Returns: String voice mail tag
getVoiceMailNumber()¶
Get the voice mail number.
Returns: String voice mail number
Device Information¶
getDeviceId()¶
Get the device ID (IMEI for GSM). Deprecated.
Returns: String device ID
getDeviceSoftwareVersion()¶
Get the device software version.
Returns: String software version
getLine1Number()¶
Get the line 1 phone number.
Returns: String phone number
checkNetworkRoaming()¶
Check if connected to roaming network.
Returns: True if roaming
Cell Info¶
getAllCellInfo()¶
Get information about all cells.
Returns: List of cell information
setDataEnabled()¶
Enable or disable mobile data.
Parameters:
- enabled (bool): True to enable, False to disable
Usage Example¶
import androidhelper
droid = androidhelper.Android()
# Get network info
operator = droid.getNetworkOperatorName().result
print(f"Operator: {operator}")
network_type = droid.getNetworkType().result
print(f"Network: {network_type}")
# Get SIM info
sim_state = droid.getSimState().result
print(f"SIM: {sim_state}")
# Get phone number
line1 = droid.getLine1Number().result
print(f"Phone: {line1}")
# Track phone state
droid.startTrackingPhoneState()
print("Tracking phone state...")
droid.stopTrackingPhoneState()