Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to switch APN programatically in android?

I am trying to develop an app in which I need to connect to a specific APN programatically for network testing purposes.

As a user, I can do this by going to "Settings" -> "Wireless & networks" -> "Mobile Networks" (long press) -> "Access Point Names". It will even let me add a new one manually.

I want to know, is there a way an app can do that automatically? I have root permissions and everything you might need.

If anyone knows the android source, can you point me on where to look to study the behavior of this screen? I've tried to take a dive there but I'm kinda lost.

like image 350
brunorey Avatar asked Jun 18 '15 13:06

brunorey


People also ask

Can APN be changed?

Best answer: APN is short of Access Point Name and provides a phone with the information needed to connect to wireless service. It can be changed by adding a new APN profile with information from the carrier in the phone's settings.

What happens if you change your APN?

What Is an APN Setting? APN settings can be modified on your smartphone (both Android and iPhone). Changing these lets your phone interface with a network provider.

What is APN Xcap?

The XML Configuration Access Protocol (XCAP) is a protocol, that allows a user to read, write, and modify application configuration data stored in XML format on a server and unlocks devices.


2 Answers

I'm answering my own question in addition to what was pointed by 7383. Hope this helps someone.

Similar to ApnEditor, I was actually looking for ApnSettings (link to cyanogen). I supposed this screen was provided by android and didn't suspect that "Settings" was actually an app.

The apps can't be used with an IDE as we usually do, it should be either compiled with makefiles like android or edit it's source so it's "ide-compatible" as suggested here

Now, to add or edit APNs you can't just put that code in any app. You need android.permission.WRITE_APN_SETTINGS which is a permission only available to system apps. The app won't be portable, but it appears this can be done using a rooted phone or a custom rom. More info here and here

like image 102
brunorey Avatar answered Oct 25 '22 11:10

brunorey


I hope you are looking for this. The following links are from Android settings app source code.

add new apn

Set as default

like image 2
siva Avatar answered Oct 25 '22 11:10

siva