導航:首頁 > IDC知識 > android域名獲取ip地址嗎

android域名獲取ip地址嗎

發布時間:2020-11-22 10:18:14

1、android怎麼獲取ip地址

一、首先來介紹蘋果系統源下查詢手機ip:
1、首先點擊【設置】按鈕

2、開啟無線區域網

3、然後選擇無線網路並連接,連接成功後,點擊所連接網路後面的驚嘆號圖標

4、然後就能看到該無線網路的詳細信息了,其中就包含了ip地址
二、介紹安卓系統下查詢手機ip地址,其方法和蘋果系統差不多:
打開系統設置,點擊進入
點擊wlan
然後進入高級設置
最後就能查看手機的mac地址和ip地址了

2、android在區域網的情況下,如何獲取伺服器的IP地址

規定一對口令,比如發出123就返回456,然後掃描網段下所有IP,對上了就是了

3、android 如何獲取本機ip地址最佳方法

/**
* 獲取ip地址
* @return
*/
public static String getHostIP() {

String hostIp = null;
try {
Enumeration nis = NetworkInterface.getNetworkInterfaces();
InetAddress ia = null;
while (nis.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface) nis.nextElement();
Enumeration<InetAddress> ias = ni.getInetAddresses();
while (ias.hasMoreElements()) {
ia = ias.nextElement();
if (ia instanceof Inet6Address) {
continue;// skip ipv6
}
String ip = ia.getHostAddress();
if (!"127.0.0.1".equals(ip)) {
hostIp = ia.getHostAddress();
break;
}
}
}
} catch (SocketException e) {
Log.i("yao", "SocketException");
e.printStackTrace();
}
return hostIp;

}

4、android 中怎麼獲取電腦ip地址

1、 選擇: 設置復 - 無線和網路制 -WLAN設置2、 按菜單鍵,然後選 高級3、 IP地址設置選項,選擇「 使用靜態IP」4、手動設置IP 地址, 大部分路由器的地址都是 192.168.1.** (XX 可以是 2-254 之間的任何數字,為了不和其他設備沖突,可以將數字設置大一些,例如 192.168.1.210等), 網關都是192.168.1.1,子網掩碼都是 255.255.255.0 ,實際情況根據路由器設置。5、設置DNS伺服器地址,大部分路由器可以設置第一個DNS為路由器地(192.168.1.1),第二個DNS地址請查看路由器撥號狀態下的DNS地址,也可以直接打電話問網路服務提供商。6、 然後 保存退出 就可以了。

5、如何獲取Android IP地址

public static String getIPAddress(Context context) {
NetworkInfo info = ((ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); if (info != null && info.isConnected()) { if (info.getType() == ConnectivityManager.TYPE_MOBILE) {//當前使用2G/3G/4G網路
try { //Enumeration<NetworkInterface> en=NetworkInterface.getNetworkInterfaces();
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) { return inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}

} else if (info.getType() == ConnectivityManager.TYPE_WIFI) {//當前使用無線網路
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String ipAddress = intIP2StringIP(wifiInfo.getIpAddress());//得到IPV4地址
return ipAddress;
}
} else { //當前無網路連接,請在設置中打開網路
} return null;
} /**
* 將得到的int類型的IP轉換為String類型
*
* @param ip
* @return
*/
public static String intIP2StringIP(int ip) { return (ip & 0xFF) + "." +
((ip >> 8) & 0xFF) + "." +
((ip >> 16) & 0xFF) + "." +
(ip >> 24 & 0xFF);
}

6、求android 把域名轉換成IP的代碼

GetInetAddress(String host)這里的來參數源host是域名,不是地址

host應為:www.網路.com, www.qq.com ,.....

7、java怎麼通過域名獲取ip地址

import java.net.InetAddress;
import java.net.UnknownHostException;
public class TestInetAddress {
InetAddress myIpAddress = null;
InetAddress[] myServer = null;
public static void main(String args[]) {
TestInetAddress address = new TestInetAddress();
System.out.println("Your host IP is: " + address.getLocalhostIP());
String domain = www.jb51.net;
System.out.println("The server domain name is: " + domain);
InetAddress[] array = address.getServerIP(domain);
int count=0;
for(int i=1; i<array.length; i++){
System.out.println("ip "+ i +" "+ address.getServerIP(domain)[i-1]);
count++;
}
System.out.println("IP address total: "+count);
}
/**
* 獲得 localhost 的IP地址
* @return
*/
public InetAddress getLocalhostIP() {
try {
myIpAddress = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return (myIpAddress);
}
/**
* 獲得某域名的IP地址
* @param domain 域名
* @return
*/
public InetAddress[] getServerIP(String domain) {
try {
myServer = InetAddress.getAllByName(domain);
} catch (UnknownHostException e) {
e.printStackTrace();
}
return (myServer);
}
}

8、如何獲取一台android手機的ip地址

果斷是坑你的錢啊。
下面是解決辦法
1.進入手機系統設置內----無線和網路容----wifi設置---菜單鍵----高級-----在下方ip設置里勾選「使用靜態ip」
2.在「使用靜態ip地址」下方,對應填寫:
ip地址:192.168.1.21(這個最後一位數可以隨意改,范圍0~255,如192.168.1.74)
網關:192.168.1.1(注意了,這里是你路由器的網關,這里是默認的地址)
網路掩碼:255.255.255.0(分為三種,詳細看電腦里的)
域名1:192.168.1.1(一般和上面的網關地址保持一致,直接上網的得修改為網路網關地址)
域名2:不填寫(特殊情況填寫)
3.保存!
之後你會發現你的wifi掉線後自動重新連接上了,之後不必再重啟路由,不會一直出現「正在獲取ip地址」的提示了

9、如何查看Android手機的DNS域,IP地址等信息

1打開手機設置抄界面,以榮耀6為例,從手機頂部向下拉,彈出界面中點擊設置。

2在設置界面中,選擇WLAN,查看可連接的wifi列表。

3長按已經連接的wifi名稱,彈出修改網路對話框,並點擊「修改網路」按鈕。

4在彈出的對話框中,勾選中「顯示高級選項」。

5隨後下拉,在IP設置這一欄選擇「靜態」。

6界面繼續往下拉,就可以看到域伺服器和IP地址的設置界面了。

10、Android 怎麼獲取手機端的ip地址

在和伺服器互動的時候,常常會用到客戶端ip地址。當然,在伺服器端可以獲取請求過來的ip,在手機端,怎麼獲取自己的ip呢?請參閱下面的函數:
[java] public static String GetHostIp() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> ipAddr = intf.getInetAddresses(); ipAddr
.hasMoreElements();) {
InetAddress inetAddress = ipAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException ex) {
} catch (Exception e) {
}
return null;
}
public static String GetHostIp() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> ipAddr = intf.getInetAddresses(); ipAddr
.hasMoreElements();) {
InetAddress inetAddress = ipAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException ex) {
} catch (Exception e) {
}
return null;
}

其實,上面的方法通過java.net下的相關類獲取ip的。主要用到的類有:java.net.NetworkInterface和java.net.InetAddress

與android域名獲取ip地址嗎相關的知識