Is it possible to get the IP address of the device using some code?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Simply use Volley to get the ip from this site
If you have a shell ; ifconfig eth0 worked for x86 device too
Please check this code...Using this code. we will get ip from mobile internet...
I don't do Android, but I'd tackle this in a totally different way.
Send a query to Google, something like: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=my%20ip
And refer to the HTML field where the response is posted. You may also query directly to the source.
Google will most like be there for longer than your Application.
Just remember, it could be that your user does not have internet at this time, what would you like to happen !
Good Luck
I used following code: The reason I used hashCode was because I was getting some garbage values appended to the ip address when I used
getHostAddress
. ButhashCode
worked really well for me as then I can use Formatter to get the ip address with correct formatting.Here is the example output :
1.using
getHostAddress
:***** IP=fe80::65ca:a13d:ea5a:233d%rmnet_sdio0
2.using
hashCode
andFormatter
:***** IP=238.194.77.212
As you can see 2nd methods gives me exactly what I need.