I have a problem reading APNs in Android v4.2 (Yes reading, not writing APNS), it is throwing a security exception:
No permission to write APN settings: Neither user 10068 nor current process has android.permission.WRITE_APN_SETTINGS.
Same code used to work on all previous platforms, does anyone know of any work around to this?
Thanks!
If you want to Read APN for Android 4.2 and more they are a change to do. I tested and it's work.
In Android 4.1 and below use this :
Cursor c = getContentResolver().query(Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"), null, null, null, null);
And for Android 4.2 and above use this code :
private static final String[] APN_PROJECTION = {
Telephony.Carriers.TYPE, // 0
Telephony.Carriers.MMSC, // 1
Telephony.Carriers.MMSPROXY, // 2
Telephony.Carriers.MMSPORT // 3
};
And this line :
final Cursor apnCursor =SqliteWrapper.query(context, this.context.getContentResolver(), Uri.withAppendedPath(Carriers.CONTENT_URI, "current"), APN_PROJECTION, null, null, null);
The SQLiteWrapperClass is hidden (found this class in internet)
import android.database.sqlite.SqliteWrapper;
My English is not quite good, sorry for this.