Transferencia: Delphi Obtenga información de WIFI del teléfono Android (XE8)

unidad Unit1; 
 
 
la interfaz 
 
 
usa 
 
 
  System.SysUtils, System.Types, System.UITypes, System.Classes, 
  System.Variants, 
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, 
  Androidapi.JNI. GraphicsContentViewText, Androidapi.JNIBridge, 
  Androidapi.JNI.Telephony, Androidapi.JNI.JavaTypes, FMX.Helpers.Android, 
  FMX.Layouts, FMX.Memo, FMX.ScrollBox, FMX.Controls.Presentation, Androidapi.JNI.Net 
  ; 
 
 
tipo 
  TForm3 = clase (TForm) 
    Memo1: TMemo; 
    btn1: TButton; 
    procedimiento btn1Click (remitente: TObject);
  privado { Declaraciones privadas
    } Públicas { declaraciones públicas } End ; var 
  Form3: TForm3; Implementación usos Androidapi.Helpers; { $ * & lt .fmx R } // dirección IP Entero Cadena función INT2IP (Intip: Int64): Cadena ;
 var 
  n: Int64; 
  IP4 , ip3, ip2, ip1: string ;
 begin 
  Resultado: = '' ; 
  n: = intIP shr 24 ; 
  intIP: = intIP xor (n shl 24 ); 
  ip4:
  
    
  
 
 

 
 
 
 

 
 

 
 

 
 
 
 

  = IntToStr (n); 
 
 
  n: = intIP shr  16 ; 
  intIP: = intIP xor (n shl  16 ); 
  ip3: = IntToStr (n); 
 
 
  n: = intIP shr  8 ; 
  intIP: = intIP xor (n shl  8 ); 
  ip2: = IntToStr (n); 
 
 
  n: = intIP; 
  ip1: = IntToStr (n); 
 
 
  Resultado: = ip1 + ' . ' + ip2 + ' . 'IP3 + + ' ' + IP4;
 Fin ; // dirección IP de cadena a entero (no medido sobre) la función ip2Int ( const TIRA: Cadena ): Int64;
 var 
  LST: un TStringList; 
  I: Integer; al comenzar 
  Resultado: = 0 ; 
  lst: = TStringList. Crear ;
   pruebe 
    lst.Delimiter: = ' . ' ; 
    lst.DelimitedText: = strIP; para i: = 0 a lst.Count- 1 do
 
 



 
 
      
      resultado: = resultado + StrToInt64 (lst [i]) shl ( 24 - i * 8 );
  finalmente 
    lst.Free; 
  terminar ;
terminar ; 
 
 
procedimiento TForm3.btn1Click (remitente: TObject);

  Servicio var : JObject; 
 
 
  WifiManager: JWifiManager; 
  ConnectionInfo: JWifiInfo; 
  Resultados de escaneo: JList; 
  ScanResult: JScanResult; 
  I: entero; 
  iIP: Int64; 
comenzar 
  Memo1.Lines.Clear; 
 
 
  Servicio: = SharedActivity.getSystemService (TJContext.JavaClass.WIFI_SERVICE); 
  WifiManager: = TJWifiManager.Wrap ((Serviciocomo ILocalObject) .GetObjectID);
  si  no es WifiManager.isWifiEnabled, entonces 
    Memo1.Lines.Add ( ' Wifi está deshabilitado ' ) de lo
   contrario comienza 
    ConnectionInfo: = WifiManager.getConnectionInfo; 
    Memo1.Lines.Add ( ' Información de conexión ' ); 
    Memo1.Lines.Add ( '   SSID: ' + JStringToString (ConnectionInfo.getSSID)); 
    Memo1.Lines.Add ( '   BSSID: ' + JStringToString (ConnectionInfo.getBSSID)); 
    Memo1.Lines.Add ( '
    IPV4: ' +   int2Ip (ConnectionInfo.getIpAddress)); 
 
 
    Memo1.Lines.Add ( '   Dirección MAC: ' + JStringToString (ConnectionInfo.getMacAddress)); 
    ScanResults: = WifiManager.getScanResults;
    para I: = 0  a ScanResults.size - 1  do comenzar 
      Memo1.Lines.Add ( '' ); 
      Memo1.Lines.Add ( ' Punto de acceso detectado ' + IntToStr (I)); 
      ScanResult: = TJScanResult.Wrap ((ScanResults.get (I) como ILocalObject) .GetObjectID);
    
      Memo1.Lines.Add ( '   SSID: ' + JStringToString (ScanResult.SSID)); 
      Memo1.Lines.Add ( '   BSSID: ' + JStringToString (ScanResult.BSSID)); 
      Memo1.Lines.Add ( '   Capacidades: ' + JStringToString (ScanResult.capabilities)); 
      Memo1.Lines.Add ( '   Frecuencia: ' + IntToStr (ScanResult.frequency) + ' MHz ' ); 
      Memo1.Lines.Add ( '   Nivel de señal: ' + IntToStr (ScanResult.level) + ' dBm ' );
    
  
; 
 
 
fin . 
———————————————— 
Aviso de Copyright: Este artículo es un artículo original del blogger de CSDN "Decode Liu Yongfeng", siguiendo el acuerdo de copyright CC 4.0 BY- SA, adjunte el texto original para su reimpresión Enlace de origen y esta declaración. 
Enlace original: https: // blog.csdn.net/lyf_lyf/java/article/details/48169575

 

Supongo que te gusta

Origin www.cnblogs.com/timba1322/p/12681581.html
Recomendado
Clasificación