在 Delphi 中实施 addDefaultNetworkActiveListener
implementing addDefaultNetworkActiveListener in Delphi
使用 here, I was able to get the status of network. But I also need to implement the event for when the status changes. I know I have to use the addDefaultNetworkActiveListener 过程中提到的解决方案,但我在使用 OnNetworkActiveListener
的界面时遇到问题。有谁知道 OnNetworkActiveListener
的界面是什么样子的?
谢谢
山姆
你需要构建这样的东西:
uses
Androidapi.JNIBridge, Androidapi.JNI.Net;
type
TNetworkActiveListener = class(TJavaLocal, JConnectivityManager_OnNetworkActiveListener)
public
procedure onNetworkActive; cdecl;
end;
然后声明一个变量:
FNetworkActiveListener: TNetworkActiveListener;
创建并添加:
FNetworkActiveListener := TNetworkActiveListener.Create;
// Use the code from the other answer for GetConnectivityManager
GetConnectivityManager.addDefaultNetworkActiveListener(FNetworkActiveListener);
使用 here, I was able to get the status of network. But I also need to implement the event for when the status changes. I know I have to use the addDefaultNetworkActiveListener 过程中提到的解决方案,但我在使用 OnNetworkActiveListener
的界面时遇到问题。有谁知道 OnNetworkActiveListener
的界面是什么样子的?
谢谢 山姆
你需要构建这样的东西:
uses
Androidapi.JNIBridge, Androidapi.JNI.Net;
type
TNetworkActiveListener = class(TJavaLocal, JConnectivityManager_OnNetworkActiveListener)
public
procedure onNetworkActive; cdecl;
end;
然后声明一个变量:
FNetworkActiveListener: TNetworkActiveListener;
创建并添加:
FNetworkActiveListener := TNetworkActiveListener.Create;
// Use the code from the other answer for GetConnectivityManager
GetConnectivityManager.addDefaultNetworkActiveListener(FNetworkActiveListener);