android current apn state and the method to get it
- 2020-05-07 20:28:22
- OfStack
The apns-conf.xml file is stored under the etc path of most android machines. The apn information used by the current machine can be seen by push through the root machine, and the specific path can be searched online
static Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
ContentResolver cResolver = context.getContentResolver();
Cursor cr = cResolver.query(PREFERRED_APN_URI, null, null, null, null);
cr.moveToFirst();
String user = cr.getString(cr.getColumnIndex("user"));
String pass = cr.getString(cr.getColumnIndex("password"));
// Then to obtain the user name and password to do relevant processing to obtain the corresponding apn state