Why do you say that?
Here's another one if you don't like that one:
* public static String int_ip_to_string (int hostAddress) {*
* byte[] addressBytes = { (byte)(0xff & hostAddress),*
* (byte)(0xff & (hostAddress >> 8)),*
* (byte)(0xff & (hostAddress >> 16)),*
* (byte)(0xff & (hostAddress >> 24)) };*
*
*
* try {*
* return InetAddress.getByAddress(addressBytes).getHostAddress();*
* } catch (UnknownHostException e) {*
* throw new AssertionError();*
* }*
* }*
On Monday, February 18, 2013 4:58:19 PM UTC-6, Larry Meadors wrote:
>
> If that gem ever shows up in one of my projects, I'll hunt you down
> and give you a wedgie.
>
> Larry
>
>
> On Mon, Feb 18, 2013 at 3:11 PM, bob <[email protected]<javascript:>>
> wrote:
> > I forgot… I had this code already in my other project:
> >
> > WifiManager wifiManager = (WifiManager)
> > getSystemService(Context.WIFI_SERVICE);
> > WifiInfo wifiInfo = wifiManager.getConnectionInfo();
> > int ipAddress = wifiInfo.getIpAddress();
> >
> > String ip = String.format("%d.%d.%d.%d", (ipAddress & 0xff),
> > (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff),
> > (ipAddress >> 24 & 0xff));
> >
> > Thanks.
> >
> >
> >
> > On Monday, February 18, 2013 3:55:32 PM UTC-6, Larry Meadors wrote:
> >>
> >>
> http://stackoverflow.com/questions/1957637/java-convert-int-to-inetaddress
> >>
> >> On Mon, Feb 18, 2013 at 2:47 PM, bob <[email protected]> wrote:
> >> > I have this code to get an IP address in Android:
> >> >
> >> > WifiManager wifiManager = (WifiManager)
> getSystemService(WIFI_SERVICE);
> >> > WifiInfo wifiInfo = wifiManager.getConnectionInfo();
> >> > int ipAddress = wifiInfo.getIpAddress();
> >> >
> >> > Is there any easy way to convert this to a String?
> >> >
> >> > Thanks.
> >> >
> >> > --
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "Android Developers" group.
> >> > To post to this group, send email to [email protected]
> >> > To unsubscribe from this group, send email to
> >> > [email protected] <javascript:>
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/android-developers?hl=en
> >> > ---
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Android Developers" group.
> >> > To unsubscribe from this group and stop receiving emails from it,
> send
> >> > an
> >> > email to [email protected]<javascript:>.
>
> >> > For more options, visit https://groups.google.com/groups/opt_out.
> >> >
> >> >
> >
> > --
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to
> > [email protected]<javascript:>
> > To unsubscribe from this group, send email to
> > [email protected] <javascript:>
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
> > ---
> > You received this message because you are subscribed to the Google
> Groups
> > "Android Developers" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.