Hello

On android API 20+ (previous API levels had the apn read blocked), I have a 
problem detecting the currently selected APN when the device changes it 
(when going to another country and changing from the current network to 
roaming). The preferapn does not change, it always return the same value:

Uri uri = Uri.parse("content://telephony/carriers/preferapn");
Cursor cursor = getContentResolver().query(uri, new String[] 
{Telephony.Carriers.APN}, null, null, 
Telephony.Carriers.DEFAULT_SORT_ORDER);
if (null != cursor) {
    try {
        while (cursor.moveToNext()) {
            String apn = 
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN));
            Log.d("APNs",apn);
        }
    } finally {
        cursor.close();
    }
}

But if I manually go to the APN settings (Settings -> More -> Mobile 
networks -> Access point names), when I go back to the app, the returned 
value changes to the new value.

The list of current APN is automatically changing, I don't have to go to 
the APN settings menu to get the changes, but querying the 
telephony/carriers or telephony/carriers/current I can't find a way to see 
the selected APN:

Uri uri = Uri.parse("content://telephony/carriers/current");
Cursor cursor = getContentResolver().query(uri, new String[] 
{Telephony.Carriers.APN}, null, null, 
Telephony.Carriers.DEFAULT_SORT_ORDER);
if (null != cursor) {
    try {
        while (cursor.moveToNext()) {
            String apn = 
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN));
            Log.d("APNs",apn);
        }
    } finally {
        cursor.close();
    }
}

Has anyone have a clue of why the preferapn isn't updating when the network 
changes?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/8d5f313a-9111-4a46-94b7-5dbf2c09821b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to