Android中的外部IP地址以编程方式 [英] External ip address in Android programmatically

查看:98
本文介绍了Android中的外部IP地址以编程方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处搜索了如何获取外部IP地址,但无济于事.我能够成功获取本地IP地址.

I have searched everywhere on how to get the external ip address with no avail. I am able to successfully get the local ip address.

简而言之,我想获得与我在whatip.com或whatismyipaddress.com上相同的IP地址的操作.但是,我不想打任何电话,是否有内置的方式来获取此信息?

In short what i want to do to get the same ip address as when I go on whatip.com or whatismyipaddress.com. However, I do not want to make any calls to the websites, is there a built in way to get this?

此外,如果用户连接到wifi,我还需要外部ipaddress.

Also, I want the external ipaddress if the user is connected to wifi.

推荐答案

但是,我不想打任何电话,是否有内置的方式来获取此信息?

However, I do not want to make any calls to the websites, is there a built in way to get this?

不.在大多数硬件上,包括台式机和笔记本电脑,更不用说电话,这是不可能的.通常,您要使用某种NAT,它定义了您的外部IP地址".

No. This is impossible on most pieces of hardware, including desktops and notebooks, let alone phones. Generally, you are behind some sort of NAT, which defines your "external ip address".

这篇关于Android中的外部IP地址以编程方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆