is there any way to set APN programmatically in blackberry?
Asked Answered
B

1

6

We can get APN Name in Blackberry but can i know is there any way to set APN in an application. Kindly help me out on this?

Thanks in Advance

Bezel answered 17/9, 2012 at 6:35 Comment(1)
I didn't expect that so many people are interestedAsomatous
A
7

Sure you can. But I think you know that apn is option for direct connection only. And I think you know that it doesn't work on many carriers. So it's preferable to use wifi, bis-b, wap2. But maybe your are targeting on specific carrier.

Preferable if target is 5.0+:

ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setPreferedTransportTypes(new int[] {..., TransportInfo.TRANSPORT_TCP_CELLULAR,...});
TcpCellularOptions transportOptions = new TcpCellularOptions();
transportOptions.setApn("<your apn>");
transportOptions.setTunnelAuthUsername("<username if required>");
transportOptions.setTunnelAuthPassword("<password if required>");
connectionFactory.setTransportTypeOptions(TransportInfo.TRANSPORT_TCP_CELLULAR, transportOptions);

Rudimental if target is below 5.0 OS:

connection = (<corresponded connection class type>)Connector.open("<your connection prefix>" + ";deviceside=false;apn=<your apn name>;TunnelAuthUsername=<username if required>;TunnelAuthPassword=<password if required>")
Asomatous answered 17/9, 2012 at 6:53 Comment(5)
Thanks for reply, can you please give me the complete explanation of the above codeBezel
What exactly should be explained?Asomatous
why you used connection Factory?Bezel
connection = (<corresponded connection class type>)Connector.open("<your connection prefix>" + ";deviceside=false;apn=<your apn name>;TunnelAuthUsername=<username if required>;TunnelAuthPassword=<password if required>") and where to use this code?Bezel
The code with Connector class should be used if your target OS is below 5.0 - 4.5, 4.6, 4.7. If you'll try ConnectionFactory in 4.6 you won't be able to run application because ConnectionFactory API was introduced in 5.0 by RIMAsomatous

© 2022 - 2024 — McMap. All rights reserved.