Get Charging Type
Summary
- Internal name:
GetChargingType - Category: Battery
- Purpose: Read the type of charger currently connected to the device. Returns
USB,AC,Wireless, orNone. - Task type: Normal
Compatibility
-
Minimum AndroMate version:
1.1.0 -
Maximum AndroMate version:
1.1.0 -
Minimum Android:
Android 13 (API 33) -
Maximum Android tested:
Android 16 (API 36) -
Required permissions: None
Detailed description
The Get Charging Type task reads the charger type from the Android battery broadcast (ACTION_BATTERY_CHANGED). The result indicates whether the device is connected via USB, an AC wall adapter, wireless charging, or is not connected to any charger. The result is stored as a string in value_output.
No special permissions are required — ACTION_BATTERY_CHANGED is a protected system broadcast available to all apps.
Input parameters
This task has no input parameters.
Output parameters
| Field | Type | Trigger condition | Android Compatibility | AndroMate Compatibility | Default |
|---|---|---|---|---|---|
value_output |
String | Always on success — one of USB, AC, Wireless, None |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | <ANDROMATE_NULL_VALUE> |
Possible output values
| Value | Description |
|---|---|
USB |
Device is charging via a USB connection |
AC |
Device is charging via an AC wall adapter |
Wireless |
Device is charging wirelessly (Qi or similar) |
None |
No charger is connected |
Special variables
When comparing the output of this task in a condition (e.g. Compare Strings), you can use the built-in AndroMate special variables instead of hardcoded strings. This avoids typos and keeps your workflow readable.
| Special variable | Resolved value |
|---|---|
${CHARGING_TYPE_USB} |
"USB" |
${CHARGING_TYPE_AC} |
"AC" |
${CHARGING_TYPE_WIRELESS} |
"Wireless" |
${CHARGING_TYPE_NONE} |
"None" |
Example — compare $charging_type against ${CHARGING_TYPE_AC} in a Compare Strings task instead of typing "AC" manually.
Exceptions
This task does not throw exceptions. If no charger is connected, "None" is stored in value_output.
Execution flowchart
flowchart TD
Start([▶ GetChargingType]) --> Register[📡 Register ACTION_BATTERY_CHANGED\none-shot receiver]
Register --> ReadPlugged[🔌 Read EXTRA_PLUGGED\nmap to string]
ReadPlugged --> StoreResult[💾 Set value_output\nStrTaskResult]
StoreResult --> LogReport[📋 Log report]
LogReport --> Success([✅ StrTaskResult])
style Start fill:#e3f2fd
style Success fill:#c8e6c9
style Register fill:#fff9c4
style ReadPlugged fill:#f3e5f5
style StoreResult fill:#c8e6c9
How it works:
- Register battery receiver: registers a one-shot receiver for
ACTION_BATTERY_CHANGED - Read plugged state: extracts
EXTRA_PLUGGEDand maps the integer constant to a charger type string - Store result: sets
value_outputwith the charger type string - Result: returns
StrTaskResult
Code examples
Example 1 — Read charging type
{
"GetChargingType": [
{
"id": "1",
"title": "Check charger type",
"value_output": "$charging_type"
}
]
}
Input parameter details
This task has no input parameters.
Output parameter details
value_output — Charger type
Stores the connected charger type as a string in the specified workflow variable.
- One of
USB,AC,Wireless,None Nonemeans no charger is connected- Tip: compare against the
${CHARGING_TYPE_*}special variables instead of hardcoded strings