I want to get IP address from my mobile Android.
var context = application.android.context;
var wifiMgr = context.getSystemService("wifi");
var wifiInfo = wifiMgr.getConnectionInfo();
var ip = wifiInfo.getIpAddress();
console.log('ip', ip)
The result is: JS: ip -2029999936
But in fact this is not my IP.
Can you ask me any idea?
Update:
I follow this . I have this code:
Step1. In my component add this code:
import app = require("application");
app.android.context;
constructor() {
var context = android.content.Context;
var wifiManager = app.android.context.getSystemService(context.WIFI_SERVICE);
var wInfo = wifiManager.getConnectionInfo();
var mac = wInfo.getMacAddress();
}
Step2.
In AndroidManifest.xml add
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
Error: [ts] Cannot find name 'android'. [2304] in this line: var
context = android.content.Context;
error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…