I tested two action receiver.
1.
ConnectivityManager.CONNECTIVITY_ACTION;
It cannot receive mobile data enabled or disabled if wifi connnected.
2.
TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED = "android.intent.action.ANY_DATA_STATE"
(It is hidden)
It can receive mobile data disabled if wifi connected., and cannot receive mobile data enabled.
My test device is Samsung Galaxy S4 mini LTE Korean Model(SHV-E370K) not Global Model (GT-I9195)
==========================================
If wifi connected, system does not call dataEnabled (because does not need mobile data).
So cannot receive mobile enabled state (Actually, mobile data is NOT enbaled)
I decided to schedule timer (period = 10000ms) and check getMobileDataEnabled()
.
private Method connectivityManager_getMobileDataEnabled = null;
private Method getConnectivityManager_getMobileDataEnabled() throws NoSuchMethodException {
if (connectivityManager_getMobileDataEnabled == null) {
connectivityManager_getMobileDataEnabled = ConnectivityManager.class.getMethod(
"getMobileDataEnabled",
new Class[0]);
}
return connectivityManager_getMobileDataEnabled;
}
public boolean getMobileDataEnabled()
throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Method getMobileDataEnabled = getConnectivityManager_getMobileDataEnabled();
getMobileDataEnabled.setAccessible(true);
return (Boolean) getMobileDataEnabled.invoke(mConnectivityManager);
}