Manually configuring APNs

579 views
Skip to first unread message

Kum Aar Shaurya

unread,
Jul 23, 2009, 5:07:47 AM7/23/09
to android-platform
Hello,
I would like to know how to manually edit the .xml files so as to
store an APN configuration.
I am working on a port of Android onto the HTC P3400.
logcat tells me that
"Failed setting numeric 'null' to the current operator"
once i save the settings through the interface, even though I have
input the carrier name, APN, and the MCC&MNC codes

It seems that there is some xml file under /system/data/data/
com.android.providers.telephony/shared_prefs/preferred-apn.xml

So can I directly edit that? How do I go about it?
Thanks in advance :)

Jean-Baptiste Queru

unread,
Jul 23, 2009, 8:43:46 AM7/23/09
to android-...@googlegroups.com
This question is off-topic on android-platform, please re-post on
android-porting.

JBQ
--
Jean-Baptiste M. "JBQ" Queru
Software Engineer, Android Open-Source Project, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.

Gary Wang

unread,
Jul 23, 2009, 9:50:20 AM7/23/09
to android-...@googlegroups.com
I think you shouldo the following operations,

1.    add “<uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>” to Application’s AndroidManifest.xml
2.    Refer the following codes to setup APN settings by

    public static final String PREFERRED_APN_URI =
        "content://telephony/carriers/preferapn";       
    private static final Uri PREFERAPN_URI = Uri.parse(PREFERRED_APN_URI);
    public static final String APN_ID = "apn_id";  
    ...
    private void setSelectedApnKey(String key) {
        ContentResolver resolver = getContentResolver();
        ContentValues values = new ContentValues();
        values.put(APN_ID, key);
        resolver.update(PREFERAPN_URI, values, null, null);
    }
    ....   
    //select target APN setting by its id (from "Telephony.Carriers.CONTENT_URI")
    setSelectedApnKey(targetApnId);
    ....

FYI
Reply all
Reply to author
Forward
0 new messages