如何用Delphi XE Android实现手机和wifi串行口模块通信
展开全部
uses System.SysUtils,
Androidapi.Helpers,
Androidapi.JNIBridge,
Androidapi.Jni.Net,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.JavaTypes,
FMX.Helpers.Android;
function GetWIFIIP:string;
var
WFM:JObject;
WifiManager:JWifiManager;
WifiInfo:JWifiInfo;
IP:Integer;
begin
WFM:=TAndroidHelper.Context.getSystemService(TJContext.JavaClass.WIFI_SERVICE);
WifiManager:=TJWifiManager.Wrap((WFM as ILocalObject).GetObjectID);
WifiInfo:=WifiManager.getConnectionInfo;
IP:=WifiInfo.getIpAddress;
Result:=Format('%d.%d.%d.%d',[Lo(IP),Hi(IP),Lo(IP shr 16),IP shr 24]);
end;
//安卓系统WIFI下获取本机IP
Androidapi.Helpers,
Androidapi.JNIBridge,
Androidapi.Jni.Net,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.JavaTypes,
FMX.Helpers.Android;
function GetWIFIIP:string;
var
WFM:JObject;
WifiManager:JWifiManager;
WifiInfo:JWifiInfo;
IP:Integer;
begin
WFM:=TAndroidHelper.Context.getSystemService(TJContext.JavaClass.WIFI_SERVICE);
WifiManager:=TJWifiManager.Wrap((WFM as ILocalObject).GetObjectID);
WifiInfo:=WifiManager.getConnectionInfo;
IP:=WifiInfo.getIpAddress;
Result:=Format('%d.%d.%d.%d',[Lo(IP),Hi(IP),Lo(IP shr 16),IP shr 24]);
end;
//安卓系统WIFI下获取本机IP
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询