I am building a network monitor app. Here I have successfully implemented all the things like track data usage from Wifi or mobile data, but I want to know which SIM is connected to internet and consuming mobile data.
Using below code I am able to know if my dual sim phone is connected to Wifi or mobile data.
public static String isInternetConnected (Context ctx) {
ConnectivityManager connectivityMgr = (ConnectivityManager) ctx
.getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo wifi = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo mobile = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
// Check if wifi or mobile network is available or not. If any of them is
// available or connected then it will return true, otherwise false;
if (wifi != null) {
if (wifi.isConnected()) {
return "wifi";
}
}
if (mobile != null) {
if (mobile.isConnected()) {
return "mobile";
}
}
return "none";
}
How can I get SIM Index or sim operator name that is consuming mobile data in dual sim android phone?
I had searched a lot and I saw many question posted in SO without answer like this.
I am able to get subId of both SIM in dual SIM phone but I am phasing problem to know which SIM is using internet.
Many other application are able to do this like Mubble.
Can any one provide me a solution for it?