Using a custom APN for a connection
I am developing an application where I need to make a connection to a server which is only accessible through a special APN. Therefore, I want to know, is it possible to specify an APN to use for a single connection 开发者_JAVA百科(or application) only, and use that, possibly even if wifi is active?
Firstly, your application will probably need the WRITE_APN_SETTINGS permission in order to be able to make APN changes. You can bring up a UI interface to have the user configure the APN with this code:
Intent intent = new Intent(Settings.ACTION_APN_SETTINGS);
startActivity(intent);
Changing the settings programatically, on the other hand, is a bit more difficult. I recommend you take a look at the answers to this similar question for more information.
精彩评论