Proper way to handle Ip address changes in Android

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The very first problem is that "Active IP address" is something that 
doesn't exists. Told like that it makes no sense on any good OS. It's 
not specific to Android !

Something important to understand is that an OS can have several IP 
addresses. Then it's network routes and rules that allows to connect the 
rest of the universe.
So for example if you have two interfaces (wifi + vpn for example), you 
have at least 2 IP.
Besides on recent android phones + recent networks you'll also get ipv6 
addresses. So even with one "network" you'll get two addresses. (I 
obviously exclude loopback address that is again another one).
What you could try is to get the ipv4 address of the interface connected 
to the default gateway. At least with that as target, you are searching 
something that you can find. (while searching "active ip address" is 
something that makes no sense). To search the ipv4 address of the 
interface connected to default gateway several solutions. Maybe with 
java api, or maybe with network route files.
If you have a server address to test it would be easier to open a socket 
to it and see your local address however (as doing that automatically 
resolves routes and interfaces).



On 22/08/2012 17:16, shawn wang wrote:
> Hi,R?gis :
>     Do you know the best way to obtain current active ip address on 
> Android? Because I have a device
> that allow two types of network connected at the same time, then when 
> iterating networking interface, we
> will get two ip addresses, but we don't know which is the one that is 
> being used by the system.
>
> On Wed, Aug 22, 2012 at 12:32 AM, R?gis Montoya <r3gis.3r at gmail.com 
> <mailto:r3gis.3r at gmail.com>> wrote:
>
>     Hi Shaun,
>
>     From my experience on CSipSimple it's not something that is
>     relevant of the sip stack.
>     Besides, it's not simple to support on android and may depend on
>     your approach on that. Depending on whether you'd like to support
>     VPN connection /for example/ approach will be different. It will
>     also be different depending on what android version you'd like to
>     support.
>     You can get inspired on what's done on Android stock SIP
>     application... BTW, you'll see it's also not responsibility of the
>     sip stack but of the sip application to decide whether to restart
>     or not the sip stack in the implementation from Google too... so I
>     think that's not a bad idea ;).
>
>     Best regards,
>     R?gis
>
>
>     On 21/08/2012 18:24, Shaun Clark wrote:
>>     When the Android app goes between wifi and 3g the call does not
>>     automatically switch, I can call 'n' which re-does the NAT, but
>>     then looking at this page:
>>     http://trac.pjsip.org/repos/wiki/IPAddressChange none of these
>>     approaches seem to work. Since mobile phones often switch back
>>     and forth between wifi and 3g/mobile this seems like a great
>>     feature to build into pjsip. Is there a way to easily handle this
>>     now on Android? Thanks!
>>
>>     Shaun
>>
>>
>>     _______________________________________________
>>     Visit our blog:http://blog.pjsip.org
>>
>>     pjsip mailing list
>>     pjsip at lists.pjsip.org  <mailto:pjsip at lists.pjsip.org>
>>     http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>
>     _______________________________________________
>     Visit our blog: http://blog.pjsip.org
>
>     pjsip mailing list
>     pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>
>     http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>
>
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20120822/31e9940a/attachment-0001.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux