如何使用Nativescript时,我的手机阅读的IP地址

问题描述 投票:-1回答:1

在我的项目,我需要创建一个接收它使用电话的IP地址的功能。我的问题是怎么样?我没有为这个工作之前,和我没有找到任何信息来帮助我。拜托,你能不能给我任何想法如何做到这一点?我可以使用哪些库/插件读取我的电话的IP地址?

import * as application from 'application';
import { android } from "application";
var context = application.android.context;
var  wifiMgr = context.getSystemService("wifi");
var wifiInfo = wifiMgr.getConnectionInfo();
var ip = wifiInfo.getIpAddress();
console.log('android.context',android.context)
var  ipAddress = android.context.format.Formatter.formatIpAddress(ip);

显示格式化未定义

android angular typescript mobile ip
1个回答
0
投票

为了让无线上网的IP地址,你可以使用此代码:

WifiManager wManager = (WifiManager) 
getSystemService(WIFI_SERVICE);
String ipAddress =Formatter.formatIpAddress(wManager.getConnectionInfo().getIpAddress());
© www.soinside.com 2019 - 2024. All rights reserved.