Which Android SDK class can be used to change settings, such as APN, E911, or CMAS

I want to know if anyone can point out a good source to explain how to use the Android SDK to change the settings related to telephone operators, such as APN, E911 and CMAS. I noticed that the telephone manager class is carrierconfigmanager, but I'm not sure which will provide read / write access, which is the best, or there is a better method

resolvent:

You can change APN by using the content provider provided by telephone.carriers

The following is the code I use to create a new APN

public void saveApn(Apn newApn) {
    String name = checkNotSet(newApn.getName());
    String apn = checkNotSet(newApn.getApn());
    String mcc = checkNotSet(newApn.getMcc());
    String mnc = checkNotSet(newApn.getMnc());

    ContentValues values = new ContentValues();

    values.put(Telephony.Carriers.NAME, name);
    values.put(Telephony.Carriers.APN, apn);

    values.put(Telephony.Carriers.MCC, mcc);
    values.put(Telephony.Carriers.MNC, mnc);
    values.put(Telephony.Carriers.NUMERIC, mcc + mnc);


    mContext.getContentResolver().insert(Telephony.Carriers.CONTENT_URI, values)
}

And set as the preferred APN

private void setAsPreferedApn(int apnId) {
    ContentValues values = new ContentValues();
    values.put("apn_id", String.valueOf(apnId));
    getContentResolver().update(Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "preferapn"), values, null, null);
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>