├── ActiveNetworkInfo ├── README.md ├── Screenshot_2016-12-06-00-56-20.png ├── Screenshot_2016-12-06-00-56-40.png ├── TestApp │ ├── ActiveNetInfo.dpr │ ├── ActiveNetInfo.dproj │ ├── uMain.fmx │ └── uMain.pas └── class │ └── ActiveNetworkInfo.Android.pas ├── DeviceInfo ├── DeviceInfo.dpr ├── DeviceInfo.dproj ├── README.md ├── uMain.fmx └── uMain.pas ├── README.md ├── Vibrator ├── README.md ├── TestApp │ ├── README.md │ ├── VibratorApp.dpr │ ├── VibratorApp.dproj │ ├── uMain.fmx │ └── uMain.pas └── class │ ├── Androidapi.JNI.os.Vibration.pas │ └── uVibratorHelper.pas └── WifiTestAPI ├── AndroidManifest.template.xml ├── FMXWifiTestAPI.dpr ├── FMXWifiTestAPI.dproj ├── Form.Main.fmx ├── Form.Main.pas └── class └── uUniversalReceiver.pas /ActiveNetworkInfo/README.md: -------------------------------------------------------------------------------- 1 | # FMX: Android API Examples 2 | 3 | ### unit ActiveNetworkInfo.Android: 4 | 5 | - **class function CheckPermission: Boolean;** - Check permission "android.permission.ACCESS_NETWORK_STATE" 6 | - **class function GetInfo: JNetworkInfo;** - Returns details about the currently active default data network. 7 | - **class function IsConnected: Boolean;** - Indicates whether network connectivity exists and it is possible to establish connections and pass data. 8 | - **class function GetTypeName: string;** - Return a human-readable name describe the type of the network, for example "WIFI" or "MOBILE". 9 | - **class function IsWifi: Boolean;** - Is Wi-Fi connection? 10 | - **class function IsMobile: Boolean;** - Is Mobile connection? -------------------------------------------------------------------------------- /ActiveNetworkInfo/Screenshot_2016-12-06-00-56-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrewEfimov/FMX-Android-API-Examples/68a08d101ae9fff03da0c3acb0aba41438e1766c/ActiveNetworkInfo/Screenshot_2016-12-06-00-56-20.png -------------------------------------------------------------------------------- /ActiveNetworkInfo/Screenshot_2016-12-06-00-56-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrewEfimov/FMX-Android-API-Examples/68a08d101ae9fff03da0c3acb0aba41438e1766c/ActiveNetworkInfo/Screenshot_2016-12-06-00-56-40.png -------------------------------------------------------------------------------- /ActiveNetworkInfo/TestApp/ActiveNetInfo.dpr: -------------------------------------------------------------------------------- 1 | program ActiveNetInfo; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | uMain in 'uMain.pas' {FormMain}, 7 | ActiveNetworkInfo.Android in '..\class\ActiveNetworkInfo.Android.pas'; 8 | 9 | {$R *.res} 10 | 11 | begin 12 | Application.Initialize; 13 | Application.CreateForm(TFormMain, FormMain); 14 | Application.Run; 15 | 16 | end. 17 | -------------------------------------------------------------------------------- /ActiveNetworkInfo/TestApp/ActiveNetInfo.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {0E1D96E7-213E-4A2A-9F59-6958C95C9897} 4 | 18.2 5 | FMX 6 | ActiveNetInfo.dpr 7 | True 8 | Debug 9 | Android 10 | 16 11 | Application 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Cfg_1 39 | true 40 | true 41 | 42 | 43 | true 44 | Cfg_1 45 | true 46 | true 47 | 48 | 49 | true 50 | Cfg_1 51 | true 52 | true 53 | 54 | 55 | true 56 | Base 57 | true 58 | 59 | 60 | true 61 | Cfg_2 62 | true 63 | true 64 | 65 | 66 | true 67 | Cfg_2 68 | true 69 | true 70 | 71 | 72 | $(BDS)\bin\delphi_PROJECTICNS.icns 73 | true 74 | ActiveNetInfo 75 | $(BDS)\bin\delphi_PROJECTICON.ico 76 | true 77 | true 78 | true 79 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 80 | true 81 | true 82 | true 83 | true 84 | true 85 | true 86 | .\$(Platform)\$(Config) 87 | .\$(Platform)\$(Config) 88 | false 89 | false 90 | false 91 | false 92 | false 93 | 94 | 95 | DBXSqliteDriver;RESTComponents;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;FireDACIBDriver;fmx;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;LockBoxDR;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) 96 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_96x96.png 97 | $(BDS)\bin\Artwork\Android\FM_SplashImage_426x320.png 98 | $(BDS)\bin\Artwork\Android\FM_SplashImage_470x320.png 99 | true 100 | $(BDS)\bin\Artwork\Android\FM_SplashImage_960x720.png 101 | android-support-v4.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services.dex.jar 102 | package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= 103 | Debug 104 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_36x36.png 105 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_144x144.png 106 | $(BDS)\bin\Artwork\Android\FM_SplashImage_640x480.png 107 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_48x48.png 108 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png 109 | 110 | 111 | $(BDS)\bin\default_app.manifest 112 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 113 | true 114 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 115 | DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;svnui;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;FireDACIBDriver;fmx;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;LockBoxDR;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 116 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 117 | Debug 118 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 119 | 1033 120 | 121 | 122 | $(BDS)\bin\default_app.manifest 123 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 124 | true 125 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 126 | DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;FireDACIBDriver;fmx;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;LockBoxDR;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 127 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 128 | Debug 129 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 130 | 1033 131 | 132 | 133 | DEBUG;$(DCC_Define) 134 | true 135 | false 136 | true 137 | true 138 | true 139 | 140 | 141 | 1 142 | true 143 | 144 | 145 | true 146 | true 147 | false 148 | 149 | 150 | true 151 | true 152 | 153 | 154 | false 155 | RELEASE;$(DCC_Define) 156 | 0 157 | 0 158 | 159 | 160 | true 161 | true 162 | 163 | 164 | true 165 | true 166 | 167 | 168 | 169 | MainSource 170 | 171 | 172 |
FormMain
173 | fmx 174 |
175 | 176 | 177 | Cfg_2 178 | Base 179 | 180 | 181 | Base 182 | 183 | 184 | Cfg_1 185 | Base 186 | 187 |
188 | 189 | Delphi.Personality.12 190 | Application 191 | 192 | 193 | 194 | ActiveNetInfo.dpr 195 | 196 | 197 | Microsoft Office 2000 Sample Automation Server Wrapper Components 198 | Microsoft Office XP Sample Automation Server Wrapper Components 199 | 200 | 201 | 202 | 203 | 204 | ic_launcher.png 205 | true 206 | 207 | 208 | 209 | 210 | ActiveNetInfo.exe 211 | true 212 | 213 | 214 | 215 | 216 | true 217 | 218 | 219 | 220 | 221 | libProject2.so 222 | true 223 | 224 | 225 | 226 | 227 | ic_launcher.png 228 | true 229 | 230 | 231 | 232 | 233 | splash_image.png 234 | true 235 | 236 | 237 | 238 | 239 | splash_image.png 240 | true 241 | 242 | 243 | 244 | 245 | splash_image.png 246 | true 247 | 248 | 249 | 250 | 251 | true 252 | 253 | 254 | 255 | 256 | splash_image.png 257 | true 258 | 259 | 260 | 261 | 262 | true 263 | 264 | 265 | 266 | 267 | ic_launcher.png 268 | true 269 | 270 | 271 | 272 | 273 | true 274 | 275 | 276 | 277 | 278 | ic_launcher.png 279 | true 280 | 281 | 282 | 283 | 284 | ic_launcher.png 285 | true 286 | 287 | 288 | 289 | 290 | true 291 | 292 | 293 | 294 | 295 | libProject2.so 296 | true 297 | 298 | 299 | 300 | 301 | libActiveNetInfo.so 302 | true 303 | 304 | 305 | 306 | 307 | classes.dex 308 | true 309 | 310 | 311 | 312 | 313 | true 314 | 315 | 316 | 317 | 318 | true 319 | 320 | 321 | 322 | 323 | true 324 | 325 | 326 | 327 | 328 | 0 329 | .dll;.bpl 330 | 331 | 332 | 1 333 | .dylib 334 | 335 | 336 | Contents\MacOS 337 | 1 338 | .dylib 339 | 340 | 341 | 1 342 | .dylib 343 | 344 | 345 | 1 346 | .dylib 347 | 348 | 349 | 350 | 351 | Contents\Resources 352 | 1 353 | 354 | 355 | 356 | 357 | classes 358 | 1 359 | 360 | 361 | 362 | 363 | Contents\MacOS 364 | 0 365 | 366 | 367 | 1 368 | 369 | 370 | Contents\MacOS 371 | 1 372 | 373 | 374 | 375 | 376 | 1 377 | 378 | 379 | 1 380 | 381 | 382 | 1 383 | 384 | 385 | 386 | 387 | res\drawable-xxhdpi 388 | 1 389 | 390 | 391 | 392 | 393 | library\lib\mips 394 | 1 395 | 396 | 397 | 398 | 399 | 1 400 | 401 | 402 | 1 403 | 404 | 405 | 0 406 | 407 | 408 | 1 409 | 410 | 411 | Contents\MacOS 412 | 1 413 | 414 | 415 | library\lib\armeabi-v7a 416 | 1 417 | 418 | 419 | 1 420 | 421 | 422 | 423 | 424 | 0 425 | 426 | 427 | Contents\MacOS 428 | 1 429 | .framework 430 | 431 | 432 | 433 | 434 | 1 435 | 436 | 437 | 1 438 | 439 | 440 | 441 | 442 | 1 443 | 444 | 445 | 1 446 | 447 | 448 | 1 449 | 450 | 451 | 452 | 453 | 1 454 | 455 | 456 | 1 457 | 458 | 459 | 1 460 | 461 | 462 | 463 | 464 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 465 | 1 466 | 467 | 468 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 469 | 1 470 | 471 | 472 | 473 | 474 | 1 475 | 476 | 477 | 1 478 | 479 | 480 | 1 481 | 482 | 483 | 484 | 485 | 1 486 | 487 | 488 | 1 489 | 490 | 491 | 1 492 | 493 | 494 | 495 | 496 | library\lib\armeabi 497 | 1 498 | 499 | 500 | 501 | 502 | 0 503 | 504 | 505 | 1 506 | 507 | 508 | Contents\MacOS 509 | 1 510 | 511 | 512 | 513 | 514 | 1 515 | 516 | 517 | 1 518 | 519 | 520 | 1 521 | 522 | 523 | 524 | 525 | res\drawable-normal 526 | 1 527 | 528 | 529 | 530 | 531 | res\drawable-xhdpi 532 | 1 533 | 534 | 535 | 536 | 537 | res\drawable-large 538 | 1 539 | 540 | 541 | 542 | 543 | 1 544 | 545 | 546 | 1 547 | 548 | 549 | 1 550 | 551 | 552 | 553 | 554 | Assets 555 | 1 556 | 557 | 558 | Assets 559 | 1 560 | 561 | 562 | 563 | 564 | ..\ 565 | 1 566 | 567 | 568 | ..\ 569 | 1 570 | 571 | 572 | 573 | 574 | res\drawable-hdpi 575 | 1 576 | 577 | 578 | 579 | 580 | library\lib\armeabi-v7a 581 | 1 582 | 583 | 584 | 585 | 586 | Contents 587 | 1 588 | 589 | 590 | 591 | 592 | ..\ 593 | 1 594 | 595 | 596 | 597 | 598 | Assets 599 | 1 600 | 601 | 602 | Assets 603 | 1 604 | 605 | 606 | 607 | 608 | 1 609 | 610 | 611 | 1 612 | 613 | 614 | 1 615 | 616 | 617 | 618 | 619 | res\values 620 | 1 621 | 622 | 623 | 624 | 625 | res\drawable-small 626 | 1 627 | 628 | 629 | 630 | 631 | res\drawable 632 | 1 633 | 634 | 635 | 636 | 637 | 1 638 | 639 | 640 | 1 641 | 642 | 643 | 1 644 | 645 | 646 | 647 | 648 | 1 649 | 650 | 651 | 652 | 653 | res\drawable 654 | 1 655 | 656 | 657 | 658 | 659 | 0 660 | 661 | 662 | 0 663 | 664 | 665 | Contents\Resources\StartUp\ 666 | 0 667 | 668 | 669 | 0 670 | 671 | 672 | 0 673 | 674 | 675 | 0 676 | 677 | 678 | 679 | 680 | library\lib\armeabi-v7a 681 | 1 682 | 683 | 684 | 685 | 686 | 0 687 | .bpl 688 | 689 | 690 | 1 691 | .dylib 692 | 693 | 694 | Contents\MacOS 695 | 1 696 | .dylib 697 | 698 | 699 | 1 700 | .dylib 701 | 702 | 703 | 1 704 | .dylib 705 | 706 | 707 | 708 | 709 | res\drawable-mdpi 710 | 1 711 | 712 | 713 | 714 | 715 | res\drawable-xlarge 716 | 1 717 | 718 | 719 | 720 | 721 | res\drawable-ldpi 722 | 1 723 | 724 | 725 | 726 | 727 | 1 728 | 729 | 730 | 1 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | True 744 | False 745 | False 746 | 747 | 748 | 12 749 | 750 | 751 | 752 | 753 | 754 | 755 |
756 | -------------------------------------------------------------------------------- /ActiveNetworkInfo/TestApp/uMain.fmx: -------------------------------------------------------------------------------- 1 | object FormMain: TFormMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'Form2' 5 | ClientHeight = 480 6 | ClientWidth = 270 7 | Padding.Left = 4.000000000000000000 8 | Padding.Top = 4.000000000000000000 9 | Padding.Right = 4.000000000000000000 10 | Padding.Bottom = 4.000000000000000000 11 | FormFactor.Width = 320 12 | FormFactor.Height = 480 13 | FormFactor.Devices = [Desktop] 14 | DesignerMasterStyle = 3 15 | object Memo1: TMemo 16 | Touch.InteractiveGestures = [Pan, LongTap, DoubleTap] 17 | DataDetectorTypes = [] 18 | StyledSettings = [Family, Style, FontColor] 19 | Align = Top 20 | Position.X = 4.000000000000000000 21 | Position.Y = 4.000000000000000000 22 | Size.Width = 262.000000000000000000 23 | Size.Height = 293.000000000000000000 24 | Size.PlatformDefault = False 25 | TabOrder = 0 26 | Viewport.Width = 254.000000000000000000 27 | Viewport.Height = 285.000000000000000000 28 | end 29 | object Button1: TButton 30 | Align = Center 31 | Size.Width = 115.000000000000000000 32 | Size.Height = 44.000000000000000000 33 | Size.PlatformDefault = False 34 | TabOrder = 2 35 | Text = 'LoadInfo' 36 | OnClick = Button1Click 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /ActiveNetworkInfo/TestApp/uMain.pas: -------------------------------------------------------------------------------- 1 | unit uMain; 2 | 3 | interface 4 | 5 | uses 6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Controls.Presentation, FMX.ScrollBox, 8 | FMX.Memo; 9 | 10 | type 11 | TFormMain = class(TForm) 12 | Memo1: TMemo; 13 | Button1: TButton; 14 | procedure Button1Click(Sender: TObject); 15 | private 16 | { Private declarations } 17 | public 18 | { Public declarations } 19 | end; 20 | 21 | var 22 | FormMain: TFormMain; 23 | 24 | implementation 25 | 26 | {$R *.fmx} 27 | 28 | uses 29 | ActiveNetworkInfo.Android; 30 | 31 | procedure TFormMain.Button1Click(Sender: TObject); 32 | begin 33 | Memo1.Lines.Clear; 34 | Memo1.Lines.Add('CheckPermission: ' + BoolToStr(TActiveNetworkInfo.CheckPermission, True)); 35 | Memo1.Lines.Add('IsConnected: ' + BoolToStr(TActiveNetworkInfo.IsConnected, True)); 36 | Memo1.Lines.Add('GetTypeName: ' + TActiveNetworkInfo.GetTypeName); 37 | Memo1.Lines.Add('IsWifi: ' + BoolToStr(TActiveNetworkInfo.IsWifi, True)); 38 | Memo1.Lines.Add('IsMobile: ' + BoolToStr(TActiveNetworkInfo.IsMobile, True)); 39 | end; 40 | 41 | end. 42 | -------------------------------------------------------------------------------- /ActiveNetworkInfo/class/ActiveNetworkInfo.Android.pas: -------------------------------------------------------------------------------- 1 | { ********************************************************************* 2 | * 3 | * Autor: Efimov A.A. 4 | * E-mail: infocean@gmail.com 5 | * GitHub: https://github.com/AndrewEfimov 6 | * Description: Getting information about connecting. 7 | * Requirements: You need permission "ACCESS_NETWORK_STATE" in the manifest. 8 | * Platform: only Android (tested on API16+) 9 | * IDE: Delphi 10.1 Berlin + 10 | * 11 | ******************************************************************** } 12 | unit ActiveNetworkInfo.Android; 13 | 14 | interface 15 | 16 | uses 17 | Androidapi.JNI.Net, Androidapi.Helpers, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.JavaTypes, 18 | Androidapi.JNI.Os; 19 | 20 | type 21 | TActiveNetworkInfo = class 22 | private 23 | class var FJConnectivityManager: JConnectivityManager; 24 | class constructor Create; 25 | public 26 | /// Check permission "android.permission.ACCESS_NETWORK_STATE" 27 | class function CheckPermission: Boolean; 28 | /// Returns details about the currently active default data network. 29 | class function GetInfo: JNetworkInfo; 30 | /// Indicates whether network connectivity exists and it is possible to establish connections and pass data. 31 | class function IsConnected: Boolean; 32 | /// Return a human-readable name describe the type of the network, for example "WIFI" or "MOBILE". 33 | class function GetTypeName: string; 34 | /// Is Wi-Fi connection? 35 | class function IsWifi: Boolean; 36 | /// Is Mobile connection? 37 | class function IsMobile: Boolean; 38 | end; 39 | 40 | implementation 41 | 42 | { TActiveNetworkInfo } 43 | 44 | class function TActiveNetworkInfo.CheckPermission: Boolean; 45 | const 46 | AccessNetworkStatePermission = 'android.permission.ACCESS_NETWORK_STATE'; 47 | var 48 | PackageName, Permission: JString; 49 | Context: JContext; 50 | PermissionGranted: Integer; 51 | begin 52 | PackageName := TAndroidHelper.Context.getPackageName; 53 | Context := TAndroidHelper.Context; 54 | Permission := StringToJString(AccessNetworkStatePermission); 55 | PermissionGranted := TJPackageManager.JavaClass.PERMISSION_GRANTED; 56 | 57 | if TJBuild_VERSION.JavaClass.SDK_INT < 23 then 58 | Result := Context.getPackageManager.CheckPermission(Permission, PackageName) = PermissionGranted 59 | else 60 | Result := Context.checkSelfPermission(Permission) = PermissionGranted; 61 | end; 62 | 63 | class constructor TActiveNetworkInfo.Create; 64 | begin 65 | FJConnectivityManager := nil; 66 | if CheckPermission then 67 | FJConnectivityManager := TJConnectivityManager.Wrap 68 | (TAndroidHelper.Context.getSystemService(TJContext.JavaClass.CONNECTIVITY_SERVICE)); 69 | end; 70 | 71 | class function TActiveNetworkInfo.GetInfo: JNetworkInfo; 72 | var 73 | NetworkInfo: JNetworkInfo; 74 | begin 75 | Result := nil; 76 | if FJConnectivityManager <> nil then 77 | begin 78 | NetworkInfo := FJConnectivityManager.getActiveNetworkInfo(); 79 | if NetworkInfo <> nil then 80 | Result := NetworkInfo; 81 | end; 82 | end; 83 | 84 | class function TActiveNetworkInfo.IsConnected: Boolean; 85 | var 86 | NetworkInfo: JNetworkInfo; 87 | begin 88 | NetworkInfo := GetInfo; 89 | Result := (NetworkInfo <> nil) and NetworkInfo.IsConnected(); 90 | end; 91 | 92 | class function TActiveNetworkInfo.IsMobile: Boolean; 93 | var 94 | NetworkInfo: JNetworkInfo; 95 | begin 96 | NetworkInfo := GetInfo; 97 | Result := (NetworkInfo <> nil) and (NetworkInfo.getType() = TJConnectivityManager.JavaClass.TYPE_MOBILE); 98 | end; 99 | 100 | class function TActiveNetworkInfo.IsWifi: Boolean; 101 | var 102 | NetworkInfo: JNetworkInfo; 103 | begin 104 | NetworkInfo := GetInfo; 105 | Result := (NetworkInfo <> nil) and (NetworkInfo.getType() = TJConnectivityManager.JavaClass.TYPE_WIFI); 106 | end; 107 | 108 | class function TActiveNetworkInfo.GetTypeName: string; 109 | const 110 | ResultNone = 'NONE'; 111 | var 112 | NetworkInfo: JNetworkInfo; 113 | begin 114 | NetworkInfo := GetInfo; 115 | if NetworkInfo <> nil then 116 | Result := JStringToString(NetworkInfo.GetTypeName()) 117 | else 118 | Result := ResultNone 119 | end; 120 | 121 | end. 122 | -------------------------------------------------------------------------------- /DeviceInfo/DeviceInfo.dpr: -------------------------------------------------------------------------------- 1 | program DeviceInfo; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | uMain in 'uMain.pas' {FormMain}; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | Application.Initialize; 12 | Application.CreateForm(TFormMain, FormMain); 13 | Application.Run; 14 | end. 15 | -------------------------------------------------------------------------------- /DeviceInfo/DeviceInfo.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {7F2DE259-DE64-4FC0-A11E-71335538CB03} 4 | 18.6 5 | FMX 6 | DeviceInfo.dpr 7 | True 8 | Debug 9 | Android 10 | 19 11 | Application 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Cfg_1 39 | true 40 | true 41 | 42 | 43 | true 44 | Cfg_1 45 | true 46 | true 47 | 48 | 49 | true 50 | Cfg_1 51 | true 52 | true 53 | 54 | 55 | true 56 | Base 57 | true 58 | 59 | 60 | true 61 | Cfg_2 62 | true 63 | true 64 | 65 | 66 | true 67 | Cfg_2 68 | true 69 | true 70 | 71 | 72 | .\$(Platform)\$(Config) 73 | .\$(Platform)\$(Config) 74 | false 75 | false 76 | false 77 | false 78 | false 79 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 80 | true 81 | true 82 | true 83 | true 84 | true 85 | true 86 | true 87 | true 88 | $(BDS)\bin\delphi_PROJECTICON.ico 89 | $(BDS)\bin\delphi_PROJECTICNS.icns 90 | DeviceInfo 91 | 92 | 93 | DBXSqliteDriver;RESTComponents;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;FmxTeeUI;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;FMXTee;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) 94 | package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= 95 | Debug 96 | true 97 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_36x36.png 98 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_48x48.png 99 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png 100 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_96x96.png 101 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_144x144.png 102 | $(BDS)\bin\Artwork\Android\FM_SplashImage_426x320.png 103 | $(BDS)\bin\Artwork\Android\FM_SplashImage_470x320.png 104 | $(BDS)\bin\Artwork\Android\FM_SplashImage_640x480.png 105 | $(BDS)\bin\Artwork\Android\FM_SplashImage_960x720.png 106 | android-support-v4.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services-ads-7.0.0.dex.jar;google-play-services-analytics-7.0.0.dex.jar;google-play-services-base-7.0.0.dex.jar;google-play-services-gcm-7.0.0.dex.jar;google-play-services-identity-7.0.0.dex.jar;google-play-services-maps-7.0.0.dex.jar;google-play-services-panorama-7.0.0.dex.jar;google-play-services-plus-7.0.0.dex.jar;google-play-services-wallet-7.0.0.dex.jar 107 | 108 | 109 | DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;svnui;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 110 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 111 | Debug 112 | true 113 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 114 | 1033 115 | $(BDS)\bin\default_app.manifest 116 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 117 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 118 | 119 | 120 | DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;tethering;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;fmx;FireDACIBDriver;fmxdae;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 121 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 122 | Debug 123 | true 124 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 125 | 1033 126 | $(BDS)\bin\default_app.manifest 127 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 128 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 129 | 130 | 131 | DEBUG;$(DCC_Define) 132 | true 133 | false 134 | true 135 | true 136 | true 137 | 138 | 139 | true 140 | 1 141 | false 142 | false 143 | false 144 | false 145 | false 146 | false 147 | false 148 | 149 | 150 | false 151 | true 152 | PerMonitorV2 153 | 154 | 155 | true 156 | PerMonitorV2 157 | 158 | 159 | false 160 | RELEASE;$(DCC_Define) 161 | 0 162 | 0 163 | 164 | 165 | true 166 | PerMonitorV2 167 | 168 | 169 | true 170 | PerMonitorV2 171 | 172 | 173 | 174 | MainSource 175 | 176 | 177 |
FormMain
178 | fmx 179 |
180 | 181 | Cfg_2 182 | Base 183 | 184 | 185 | Base 186 | 187 | 188 | Cfg_1 189 | Base 190 | 191 |
192 | 193 | Delphi.Personality.12 194 | Application 195 | 196 | 197 | 198 | DeviceInfo.dpr 199 | 200 | 201 | Microsoft Office 2000 Sample Automation Server Wrapper Components 202 | Microsoft Office XP Sample Automation Server Wrapper Components 203 | 204 | 205 | 206 | 207 | 208 | ic_launcher.png 209 | true 210 | 211 | 212 | 213 | 214 | ic_launcher.png 215 | true 216 | 217 | 218 | 219 | 220 | true 221 | 222 | 223 | 224 | 225 | libDeviceInfo.so 226 | true 227 | 228 | 229 | 230 | 231 | libDeviceInfo.so 232 | true 233 | 234 | 235 | 236 | 237 | true 238 | 239 | 240 | 241 | 242 | true 243 | 244 | 245 | 246 | 247 | true 248 | 249 | 250 | 251 | 252 | DeviceInfo.exe 253 | true 254 | 255 | 256 | 257 | 258 | splash_image.png 259 | true 260 | 261 | 262 | 263 | 264 | ic_launcher.png 265 | true 266 | 267 | 268 | 269 | 270 | true 271 | 272 | 273 | 274 | 275 | ic_launcher.png 276 | true 277 | 278 | 279 | 280 | 281 | splash_image.png 282 | true 283 | 284 | 285 | 286 | 287 | splash_image.png 288 | true 289 | 290 | 291 | 292 | 293 | splash_image.png 294 | true 295 | 296 | 297 | 298 | 299 | ic_launcher.png 300 | true 301 | 302 | 303 | 304 | 305 | true 306 | 307 | 308 | 309 | 310 | libDeviceInfo.so 311 | true 312 | 313 | 314 | 315 | 316 | true 317 | 318 | 319 | 320 | 321 | styles.xml 322 | true 323 | 324 | 325 | 326 | 327 | true 328 | 329 | 330 | 331 | 332 | true 333 | 334 | 335 | 336 | 337 | classes.dex 338 | true 339 | 340 | 341 | 342 | 343 | 1 344 | 345 | 346 | Contents\MacOS 347 | 1 348 | 349 | 350 | 0 351 | 352 | 353 | 354 | 355 | classes 356 | 1 357 | 358 | 359 | 360 | 361 | res\xml 362 | 1 363 | 364 | 365 | 366 | 367 | library\lib\armeabi-v7a 368 | 1 369 | 370 | 371 | 372 | 373 | library\lib\armeabi 374 | 1 375 | 376 | 377 | 378 | 379 | library\lib\mips 380 | 1 381 | 382 | 383 | 384 | 385 | library\lib\armeabi-v7a 386 | 1 387 | 388 | 389 | 390 | 391 | res\drawable 392 | 1 393 | 394 | 395 | 396 | 397 | res\values 398 | 1 399 | 400 | 401 | 402 | 403 | res\values-v21 404 | 1 405 | 406 | 407 | 408 | 409 | res\drawable 410 | 1 411 | 412 | 413 | 414 | 415 | res\drawable-xxhdpi 416 | 1 417 | 418 | 419 | 420 | 421 | res\drawable-ldpi 422 | 1 423 | 424 | 425 | 426 | 427 | res\drawable-mdpi 428 | 1 429 | 430 | 431 | 432 | 433 | res\drawable-hdpi 434 | 1 435 | 436 | 437 | 438 | 439 | res\drawable-xhdpi 440 | 1 441 | 442 | 443 | 444 | 445 | res\drawable-small 446 | 1 447 | 448 | 449 | 450 | 451 | res\drawable-normal 452 | 1 453 | 454 | 455 | 456 | 457 | res\drawable-large 458 | 1 459 | 460 | 461 | 462 | 463 | res\drawable-xlarge 464 | 1 465 | 466 | 467 | 468 | 469 | 1 470 | 471 | 472 | Contents\MacOS 473 | 1 474 | 475 | 476 | 0 477 | 478 | 479 | 480 | 481 | Contents\MacOS 482 | 1 483 | .framework 484 | 485 | 486 | Contents\MacOS 487 | 1 488 | .framework 489 | 490 | 491 | 0 492 | 493 | 494 | 495 | 496 | 1 497 | .dylib 498 | 499 | 500 | 1 501 | .dylib 502 | 503 | 504 | 1 505 | .dylib 506 | 507 | 508 | Contents\MacOS 509 | 1 510 | .dylib 511 | 512 | 513 | Contents\MacOS 514 | 1 515 | .dylib 516 | 517 | 518 | 0 519 | .dll;.bpl 520 | 521 | 522 | 523 | 524 | 1 525 | .dylib 526 | 527 | 528 | 1 529 | .dylib 530 | 531 | 532 | 1 533 | .dylib 534 | 535 | 536 | Contents\MacOS 537 | 1 538 | .dylib 539 | 540 | 541 | Contents\MacOS 542 | 1 543 | .dylib 544 | 545 | 546 | 0 547 | .bpl 548 | 549 | 550 | 551 | 552 | 0 553 | 554 | 555 | 0 556 | 557 | 558 | 0 559 | 560 | 561 | 0 562 | 563 | 564 | Contents\Resources\StartUp\ 565 | 0 566 | 567 | 568 | Contents\Resources\StartUp\ 569 | 0 570 | 571 | 572 | 0 573 | 574 | 575 | 576 | 577 | 1 578 | 579 | 580 | 1 581 | 582 | 583 | 1 584 | 585 | 586 | 587 | 588 | 1 589 | 590 | 591 | 1 592 | 593 | 594 | 1 595 | 596 | 597 | 598 | 599 | 1 600 | 601 | 602 | 1 603 | 604 | 605 | 1 606 | 607 | 608 | 609 | 610 | 1 611 | 612 | 613 | 1 614 | 615 | 616 | 1 617 | 618 | 619 | 620 | 621 | 1 622 | 623 | 624 | 1 625 | 626 | 627 | 1 628 | 629 | 630 | 631 | 632 | 1 633 | 634 | 635 | 1 636 | 637 | 638 | 1 639 | 640 | 641 | 642 | 643 | 1 644 | 645 | 646 | 1 647 | 648 | 649 | 1 650 | 651 | 652 | 653 | 654 | 1 655 | 656 | 657 | 658 | 659 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 660 | 1 661 | 662 | 663 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 664 | 1 665 | 666 | 667 | 668 | 669 | 1 670 | 671 | 672 | 1 673 | 674 | 675 | 676 | 677 | ..\ 678 | 1 679 | 680 | 681 | ..\ 682 | 1 683 | 684 | 685 | 686 | 687 | 1 688 | 689 | 690 | 1 691 | 692 | 693 | 1 694 | 695 | 696 | 697 | 698 | 1 699 | 700 | 701 | 1 702 | 703 | 704 | 1 705 | 706 | 707 | 708 | 709 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 710 | 1 711 | 712 | 713 | 714 | 715 | ..\ 716 | 1 717 | 718 | 719 | ..\ 720 | 1 721 | 722 | 723 | 724 | 725 | Contents 726 | 1 727 | 728 | 729 | Contents 730 | 1 731 | 732 | 733 | 734 | 735 | Contents\Resources 736 | 1 737 | 738 | 739 | Contents\Resources 740 | 1 741 | 742 | 743 | 744 | 745 | library\lib\armeabi-v7a 746 | 1 747 | 748 | 749 | 1 750 | 751 | 752 | 1 753 | 754 | 755 | 1 756 | 757 | 758 | 1 759 | 760 | 761 | Contents\MacOS 762 | 1 763 | 764 | 765 | Contents\MacOS 766 | 1 767 | 768 | 769 | 0 770 | 771 | 772 | 773 | 774 | 1 775 | 776 | 777 | 1 778 | 779 | 780 | 781 | 782 | Assets 783 | 1 784 | 785 | 786 | Assets 787 | 1 788 | 789 | 790 | 791 | 792 | Assets 793 | 1 794 | 795 | 796 | Assets 797 | 1 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | True 812 | True 813 | True 814 | 815 | 816 | 12 817 | 818 | 819 | 820 | 821 |
822 | -------------------------------------------------------------------------------- /DeviceInfo/README.md: -------------------------------------------------------------------------------- 1 | 2 | Blog Note: [Получаем информацию об устройстве (Device Information)](http://delphifmandroid.blogspot.com/2014/01/device-information.html) 3 | -------------------------------------------------------------------------------- /DeviceInfo/uMain.fmx: -------------------------------------------------------------------------------- 1 | object FormMain: TFormMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'DeviceInfo' 5 | ClientHeight = 480 6 | ClientWidth = 310 7 | FormFactor.Width = 320 8 | FormFactor.Height = 480 9 | FormFactor.Devices = [Desktop] 10 | OnCreate = FormCreate 11 | DesignerMasterStyle = 3 12 | object lbListInfo: TListBox 13 | Align = Client 14 | Size.Width = 310.000000000000000000 15 | Size.Height = 432.000000000000000000 16 | Size.PlatformDefault = False 17 | StyleLookup = 'transparentlistboxstyle' 18 | TabOrder = 0 19 | DisableFocusEffect = True 20 | DefaultItemStyles.ItemStyle = 'listboxitembottomdetail' 21 | DefaultItemStyles.GroupHeaderStyle = '' 22 | DefaultItemStyles.GroupFooterStyle = '' 23 | GroupingKind = Grouped 24 | Viewport.Width = 310.000000000000000000 25 | Viewport.Height = 432.000000000000000000 26 | end 27 | object ToolBar1: TToolBar 28 | Size.Width = 310.000000000000000000 29 | Size.Height = 48.000000000000000000 30 | Size.PlatformDefault = False 31 | TabOrder = 1 32 | object Label1: TLabel 33 | Align = Contents 34 | Size.Width = 310.000000000000000000 35 | Size.Height = 48.000000000000000000 36 | Size.PlatformDefault = False 37 | StyleLookup = 'toollabel' 38 | TextSettings.HorzAlign = Center 39 | Text = 'Device Information' 40 | TabOrder = 0 41 | end 42 | object sbLoadInfo: TSpeedButton 43 | Align = Right 44 | Margins.Right = 10.000000000000000000 45 | Position.X = 252.000000000000000000 46 | Size.Width = 48.000000000000000000 47 | Size.Height = 48.000000000000000000 48 | Size.PlatformDefault = False 49 | StyleLookup = 'infotoolbutton' 50 | Text = 'LoadInfo' 51 | OnClick = sbLoadInfoClick 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /DeviceInfo/uMain.pas: -------------------------------------------------------------------------------- 1 | unit uMain; 2 | 3 | interface 4 | 5 | uses 6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Controls.Presentation, FMX.Layouts, 8 | FMX.ListBox; 9 | 10 | type 11 | TFormMain = class(TForm) 12 | lbListInfo: TListBox; 13 | ToolBar1: TToolBar; 14 | Label1: TLabel; 15 | sbLoadInfo: TSpeedButton; 16 | procedure sbLoadInfoClick(Sender: TObject); 17 | procedure FormCreate(Sender: TObject); 18 | private 19 | { Private declarations } 20 | FPermissionReadPhoneState: string; 21 | procedure AddListItem(const AText, ADetail: string); 22 | procedure AddListHeader(const AText: string); 23 | procedure LoadInfo; 24 | public 25 | { Public declarations } 26 | end; 27 | 28 | var 29 | FormMain: TFormMain; 30 | 31 | implementation 32 | 33 | {$R *.fmx} 34 | 35 | uses 36 | System.Permissions, Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNI.Os, Androidapi.JNI.Provider, 37 | Androidapi.JNI.GraphicsContentViewText, Androidapi.JNIBridge, Androidapi.JNI, Androidapi.JNI.Bluetooth; 38 | 39 | procedure TFormMain.AddListHeader(const AText: string); 40 | var 41 | ListBoxGroupHeader: TListBoxGroupHeader; 42 | begin 43 | ListBoxGroupHeader := TListBoxGroupHeader.Create(lbListInfo); 44 | ListBoxGroupHeader.Text := AText; 45 | lbListInfo.AddObject(ListBoxGroupHeader); 46 | end; 47 | 48 | procedure TFormMain.AddListItem(const AText, ADetail: string); 49 | var 50 | ListBoxItem: TListBoxItem; 51 | begin 52 | ListBoxItem := TListBoxItem.Create(lbListInfo); 53 | ListBoxItem.Text := AText; 54 | ListBoxItem.ItemData.Detail := ADetail; 55 | lbListInfo.AddObject(ListBoxItem); 56 | end; 57 | 58 | procedure TFormMain.FormCreate(Sender: TObject); 59 | begin 60 | FPermissionReadPhoneState := JStringToString(TJManifest_permission.JavaClass.READ_PHONE_STATE); 61 | end; 62 | 63 | procedure TFormMain.LoadInfo; 64 | var 65 | SDK_INT, I, J, K: Integer; 66 | DeviceName: JString; 67 | BTAdapter: JBluetoothAdapter; 68 | SUPPORTED_32_BIT_ABIS, SUPPORTED_64_BIT_ABIS, SUPPORTED_ABIS: TJavaObjectArray; 69 | StrSUPPORTED_32, StrSUPPORTED_64, StrSUPPORTED_ABIS: string; 70 | begin 71 | SDK_INT := TJBuild_VERSION.JavaClass.SDK_INT; 72 | 73 | if SDK_INT < 17 then 74 | DeviceName := TJSettings_System.JavaClass.getString(TAndroidHelper.ContentResolver, StringToJstring('device_name')) 75 | else 76 | DeviceName := TJSettings_Global.JavaClass.getString(TAndroidHelper.ContentResolver, StringToJstring('device_name')); 77 | 78 | if DeviceName = nil then 79 | begin 80 | // android.Manifest.permission.BLUETOOTH 81 | BTAdapter := TJBluetoothAdapter.JavaClass.getDefaultAdapter; 82 | DeviceName := BTAdapter.getName; 83 | end; 84 | 85 | lbListInfo.Clear; 86 | lbListInfo.BeginUpdate; 87 | 88 | AddListHeader('Settings API'); 89 | AddListItem('DEVICE_NAME', JStringToString(DeviceName)); 90 | 91 | AddListHeader('Build API'); 92 | AddListItem('BOARD', JStringToString(TJBuild.JavaClass.BOARD)); // API 1 93 | AddListItem('BOOTLOADER', JStringToString(TJBuild.JavaClass.BOOTLOADER)); // API 8 94 | AddListItem('BRAND', JStringToString(TJBuild.JavaClass.BRAND)); // API 1 95 | 96 | if SDK_INT <= 21 then 97 | begin 98 | AddListItem('CPU_ABI', JStringToString(TJBuild.JavaClass.CPU_ABI)); // API 4 - Depr. API 21 (Use SUPPORTED_ABIS) 99 | AddListItem('CPU_ABI2', JStringToString(TJBuild.JavaClass.CPU_ABI2)); // API 8 - Depr. API 21 (Use SUPPORTED_ABIS) 100 | end; 101 | 102 | AddListItem('DEVICE', JStringToString(TJBuild.JavaClass.DEVICE)); // API 1 103 | AddListItem('DISPLAY', JStringToString(TJBuild.JavaClass.DISPLAY)); // API 3 104 | AddListItem('FINGERPRINT', JStringToString(TJBuild.JavaClass.FINGERPRINT)); // API 1 105 | AddListItem('HARDWARE', JStringToString(TJBuild.JavaClass.HARDWARE)); // API 8 106 | AddListItem('ID', JStringToString(TJBuild.JavaClass.ID)); // API 1 107 | AddListItem('MANUFACTURER', JStringToString(TJBuild.JavaClass.MANUFACTURER)); // API 4 108 | AddListItem('MODEL', JStringToString(TJBuild.JavaClass.MODEL)); // API 1 109 | AddListItem('PRODUCT', JStringToString(TJBuild.JavaClass.PRODUCT)); // API 1 110 | 111 | if SDK_INT <= 15 then 112 | AddListItem('RADIO', JStringToString(TJBuild.JavaClass.RADIO)) // API 8 - Deprecated API 15 (Use getRadioVersion()) 113 | else 114 | AddListItem('RADIO', JStringToString(TJBuild.JavaClass.getRadioVersion)); 115 | 116 | if SDK_INT <= 26 then 117 | AddListItem('SERIAL', JStringToString(TJBuild.JavaClass.SERIAL)) // API 9 - Deprecated API 26 (Use getSerial()) 118 | else 119 | // android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE 120 | AddListItem('SERIAL', JStringToString(TJBuild.JavaClass.getSerial)); 121 | 122 | 123 | if SDK_INT >= 21 then 124 | begin 125 | SUPPORTED_32_BIT_ABIS := TJBuild.JavaClass.SUPPORTED_32_BIT_ABIS; // API 21 126 | SUPPORTED_64_BIT_ABIS := TJBuild.JavaClass.SUPPORTED_64_BIT_ABIS; // API 21 127 | SUPPORTED_ABIS := TJBuild.JavaClass.SUPPORTED_ABIS; // API 21 128 | 129 | StrSUPPORTED_32 := ''; 130 | for I := 0 to SUPPORTED_32_BIT_ABIS.Length - 1 do 131 | StrSUPPORTED_32 := StrSUPPORTED_32 + JStringToString(SUPPORTED_32_BIT_ABIS.Items[I]) + ' '; 132 | 133 | StrSUPPORTED_64 := ''; 134 | for J := 0 to SUPPORTED_64_BIT_ABIS.Length - 1 do 135 | StrSUPPORTED_64 := StrSUPPORTED_64 + JStringToString(SUPPORTED_64_BIT_ABIS.Items[J]) + ' '; 136 | 137 | StrSUPPORTED_ABIS := ''; 138 | for K := 0 to SUPPORTED_ABIS.Length - 1 do 139 | StrSUPPORTED_ABIS := StrSUPPORTED_ABIS + JStringToString(SUPPORTED_ABIS.Items[K]) + ' '; 140 | 141 | AddListItem('SUPPORTED_32_BIT_ABIS', StrSUPPORTED_32); 142 | AddListItem('SUPPORTED_64_BIT_ABIS', StrSUPPORTED_64); 143 | AddListItem('SUPPORTED_ABIS', StrSUPPORTED_ABIS); 144 | end; 145 | 146 | AddListItem('TAGS', JStringToString(TJBuild.JavaClass.TAGS)); // API 1 147 | AddListItem('TIME', TJBuild.JavaClass.TIME.ToString); // API 1 148 | AddListItem('TYPE', JStringToString(TJBuild.JavaClass.&TYPE)); // API 1 149 | AddListItem('USER', JStringToString(TJBuild.JavaClass.USER)); // API 1 150 | 151 | AddListHeader('Build.VERSION API'); 152 | 153 | if SDK_INT >= 23 then 154 | AddListItem('BASE_OS', JStringToString(TJBuild_VERSION.JavaClass.BASE_OS)); // API 23 155 | 156 | AddListItem('CODENAME', JStringToString(TJBuild_VERSION.JavaClass.CODENAME)); // API 4 157 | AddListItem('INCREMENTAL', JStringToString(TJBuild_VERSION.JavaClass.INCREMENTAL)); // API 1 158 | 159 | if SDK_INT >= 23 then 160 | AddListItem('PREVIEW_SDK_INT', TJBuild_VERSION.JavaClass.PREVIEW_SDK_INT.ToString); // API 23 161 | 162 | AddListItem('RELEASE', JStringToString(TJBuild_VERSION.JavaClass.RELEASE)); // API 1 163 | 164 | if SDK_INT <= 15 then 165 | AddListItem('SDK', JStringToString(TJBuild_VERSION.JavaClass.SDK)); // API 1 - Deprecated API 15 (Use SDK_INT) 166 | 167 | AddListItem('SDK_INT', TJBuild_VERSION.JavaClass.SDK_INT.ToString); // API 4 168 | 169 | if SDK_INT >= 23 then 170 | AddListItem('SECURITY_PATCH', JStringToString(TJBuild_VERSION.JavaClass.SECURITY_PATCH)); // API 23 171 | 172 | lbListInfo.EndUpdate; 173 | end; 174 | 175 | procedure TFormMain.sbLoadInfoClick(Sender: TObject); 176 | 177 | begin 178 | PermissionsService.RequestPermissions([FPermissionReadPhoneState], 179 | procedure(const APermissions: TArray; const AGrantResults: TArray) 180 | begin 181 | if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then 182 | LoadInfo 183 | else 184 | ShowMessage('Permission Denied'); 185 | end); 186 | end; 187 | 188 | end. 189 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FMX: Android API Examples 2 | ActiveNetworkInfo - Getting information about connecting. (Получение информации о подключении) 3 | 4 | Vibrator - Class that operates the vibrator on the device. (Работа с вибрацией на устройстве) 5 | 6 | DeviceInfo - Getting device information. (Получение информации об устройстве) 7 | 8 | WifiTestAPI - Test Wifi API (Пример работы с Wifi API) -------------------------------------------------------------------------------- /Vibrator/README.md: -------------------------------------------------------------------------------- 1 | 2 | Blog Note: [Используем вибрацию на Android устройствах](https://delphifmandroid.blogspot.com/2014/01/android.html) -------------------------------------------------------------------------------- /Vibrator/TestApp/README.md: -------------------------------------------------------------------------------- 1 | App Tested on Delphi 10.3.3 -------------------------------------------------------------------------------- /Vibrator/TestApp/VibratorApp.dpr: -------------------------------------------------------------------------------- 1 | program VibratorApp; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | uMain in 'uMain.pas' {Form2}, 7 | uVibratorHelper in '..\class\uVibratorHelper.pas', 8 | Androidapi.JNI.os.Vibration in '..\class\Androidapi.JNI.os.Vibration.pas'; 9 | 10 | {$R *.res} 11 | 12 | begin 13 | Application.Initialize; 14 | Application.CreateForm(TForm2, Form2); 15 | Application.Run; 16 | 17 | end. 18 | -------------------------------------------------------------------------------- /Vibrator/TestApp/uMain.fmx: -------------------------------------------------------------------------------- 1 | object Form2: TForm2 2 | Left = 0 3 | Top = 0 4 | Caption = 'Form2' 5 | ClientHeight = 499 6 | ClientWidth = 294 7 | FormFactor.Width = 320 8 | FormFactor.Height = 480 9 | FormFactor.Devices = [Desktop] 10 | DesignerMasterStyle = 3 11 | object Layout1: TLayout 12 | Align = Client 13 | Padding.Left = 10.000000000000000000 14 | Padding.Top = 10.000000000000000000 15 | Padding.Right = 10.000000000000000000 16 | Padding.Bottom = 10.000000000000000000 17 | Size.Width = 294.000000000000000000 18 | Size.Height = 451.000000000000000000 19 | Size.PlatformDefault = False 20 | TabOrder = 0 21 | object editValue: TEdit 22 | Touch.InteractiveGestures = [LongTap, DoubleTap] 23 | Align = Top 24 | TabOrder = 0 25 | Text = '1000,2000,1000,3000' 26 | Position.X = 10.000000000000000000 27 | Position.Y = 10.000000000000000000 28 | Size.Width = 274.000000000000000000 29 | Size.Height = 32.000000000000000000 30 | Size.PlatformDefault = False 31 | TextPrompt = 'value or value, value, ..., value' 32 | end 33 | object Layout2: TLayout 34 | Align = HorzCenter 35 | Position.X = 89.000000000000000000 36 | Position.Y = 106.000000000000000000 37 | Size.Width = 115.000000000000000000 38 | Size.Height = 335.000000000000000000 39 | Size.PlatformDefault = False 40 | TabOrder = 1 41 | object butVibrateTestZero: TButton 42 | Align = Top 43 | Position.Y = 44.000000000000000000 44 | Size.Width = 115.000000000000000000 45 | Size.Height = 44.000000000000000000 46 | Size.PlatformDefault = False 47 | TabOrder = 3 48 | Text = 'Test Zero' 49 | OnClick = butVibrateTestZeroClick 50 | end 51 | object butHasVirator: TButton 52 | Align = Top 53 | Size.Width = 115.000000000000000000 54 | Size.Height = 44.000000000000000000 55 | Size.PlatformDefault = False 56 | TabOrder = 4 57 | Text = 'hasVibrator' 58 | OnClick = butHasViratorClick 59 | end 60 | object butCancel: TButton 61 | Align = Top 62 | Position.Y = 220.000000000000000000 63 | Size.Width = 115.000000000000000000 64 | Size.Height = 44.000000000000000000 65 | Size.PlatformDefault = False 66 | TabOrder = 5 67 | Text = 'Cancel' 68 | OnClick = butCancelClick 69 | end 70 | object butVibrateTestOne: TButton 71 | Align = Top 72 | Position.Y = 88.000000000000000000 73 | Size.Width = 115.000000000000000000 74 | Size.Height = 44.000000000000000000 75 | Size.PlatformDefault = False 76 | TabOrder = 2 77 | Text = 'Test One' 78 | OnClick = butVibrateTestOneClick 79 | end 80 | object butVibrateTestTwo: TButton 81 | Align = Top 82 | Position.Y = 132.000000000000000000 83 | Size.Width = 115.000000000000000000 84 | Size.Height = 44.000000000000000000 85 | Size.PlatformDefault = False 86 | TabOrder = 1 87 | Text = 'Test Two' 88 | OnClick = butVibrateTestTwoClick 89 | end 90 | object butVibrateTestThree: TButton 91 | Align = Top 92 | Position.Y = 176.000000000000000000 93 | Size.Width = 115.000000000000000000 94 | Size.Height = 44.000000000000000000 95 | Size.PlatformDefault = False 96 | TabOrder = 0 97 | Text = 'Test Three' 98 | OnClick = butVibrateTestThreeClick 99 | end 100 | end 101 | object labelHasVibrator: TLabel 102 | Align = Top 103 | AutoSize = True 104 | Margins.Top = 10.000000000000000000 105 | Margins.Bottom = 10.000000000000000000 106 | Position.X = 10.000000000000000000 107 | Position.Y = 52.000000000000000000 108 | Size.Width = 274.000000000000000000 109 | Size.Height = 44.000000000000000000 110 | Size.PlatformDefault = False 111 | TextSettings.Trimming = None 112 | Text = 'Check whether the hardware has a vibrator. ' 113 | end 114 | end 115 | object ToolBar1: TToolBar 116 | Size.Width = 294.000000000000000000 117 | Size.Height = 48.000000000000000000 118 | Size.PlatformDefault = False 119 | TabOrder = 1 120 | object Label1: TLabel 121 | Align = Center 122 | AutoSize = True 123 | Size.Width = 154.000000000000000000 124 | Size.Height = 22.000000000000000000 125 | Size.PlatformDefault = False 126 | TextSettings.WordWrap = False 127 | TextSettings.Trimming = None 128 | Text = 'Test vibrator class ' 129 | end 130 | end 131 | end 132 | -------------------------------------------------------------------------------- /Vibrator/TestApp/uMain.pas: -------------------------------------------------------------------------------- 1 | unit uMain; 2 | 3 | interface 4 | 5 | uses 6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Controls.Presentation, FMX.Edit, 8 | FMX.Layouts; 9 | 10 | type 11 | TForm2 = class(TForm) 12 | editValue: TEdit; 13 | butVibrateTestZero: TButton; 14 | butHasVirator: TButton; 15 | butCancel: TButton; 16 | Layout1: TLayout; 17 | ToolBar1: TToolBar; 18 | Label1: TLabel; 19 | Layout2: TLayout; 20 | labelHasVibrator: TLabel; 21 | butVibrateTestOne: TButton; 22 | butVibrateTestTwo: TButton; 23 | butVibrateTestThree: TButton; 24 | procedure butHasViratorClick(Sender: TObject); 25 | procedure butCancelClick(Sender: TObject); 26 | procedure butVibrateTestZeroClick(Sender: TObject); 27 | procedure butVibrateTestOneClick(Sender: TObject); 28 | procedure butVibrateTestTwoClick(Sender: TObject); 29 | procedure butVibrateTestThreeClick(Sender: TObject); 30 | private 31 | { Private declarations } 32 | public 33 | { Public declarations } 34 | function CheckPermission: Boolean; 35 | end; 36 | 37 | var 38 | Form2: TForm2; 39 | 40 | implementation 41 | 42 | {$R *.fmx} 43 | 44 | uses 45 | System.Permissions, Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNI.Os, uVibratorHelper; 46 | 47 | procedure TForm2.butHasViratorClick(Sender: TObject); 48 | begin 49 | if TVibratorHelper.hasVibrator then 50 | labelHasVibrator.Text := 'Vibrator supported' 51 | else 52 | labelHasVibrator.Text := 'Vibrator is not supported' 53 | end; 54 | 55 | procedure TForm2.butVibrateTestOneClick(Sender: TObject); 56 | const 57 | ArrayStr: array [0 .. 3] of string = ('200', '1000', '200', '2000'); 58 | begin 59 | // Test 1 60 | if CheckPermission then 61 | TVibratorHelper.vibrate(ArrayStr, 2); 62 | end; 63 | 64 | procedure TForm2.butVibrateTestThreeClick(Sender: TObject); 65 | begin 66 | // Test 3: TJavaArray 67 | if CheckPermission then 68 | TVibratorHelper.vibrate(TJavaArrayHelper.ArrayStrToJavaArrayInt64(['100', '2000', '100', '3000']), -1); 69 | end; 70 | 71 | procedure TForm2.butVibrateTestTwoClick(Sender: TObject); 72 | const 73 | ArrayInt64: array of Int64 = [500, 2000, 500, 2000]; 74 | begin 75 | // Test 2 76 | if CheckPermission then 77 | TVibratorHelper.vibrate(ArrayInt64, -1); 78 | end; 79 | 80 | procedure TForm2.butVibrateTestZeroClick(Sender: TObject); 81 | var 82 | Value: string; 83 | begin 84 | Value := Trim(editValue.Text); 85 | if CheckPermission then 86 | if Value.Contains(',') then 87 | TVibratorHelper.vibrate(Value.Split([',']), -1) 88 | else 89 | TVibratorHelper.vibrate(Value.ToInt64); 90 | end; 91 | 92 | function TForm2.CheckPermission: Boolean; 93 | begin 94 | Result := PermissionsService.IsPermissionGranted(JStringToString(TJManifest_permission.JavaClass.vibrate)); 95 | end; 96 | 97 | procedure TForm2.butCancelClick(Sender: TObject); 98 | begin 99 | if CheckPermission then 100 | TVibratorHelper.cancel; 101 | end; 102 | 103 | end. 104 | -------------------------------------------------------------------------------- /Vibrator/class/Androidapi.JNI.os.Vibration.pas: -------------------------------------------------------------------------------- 1 | { ********************************************************************* 2 | * 3 | * Autor: Efimov A.A. 4 | * E-mail: infocean@gmail.com 5 | * GitHub: https://github.com/AndrewEfimov 6 | * Platform: Android (package android.os classes Vibrator and VibrationEffect) 7 | * IDE: Delphi 10.1 Berlin + 8 | * Change: 18.11.2019 All API (Include API 29) 9 | * 10 | ******************************************************************** } 11 | 12 | unit Androidapi.JNI.os.Vibration; 13 | 14 | interface 15 | 16 | uses 17 | Androidapi.JNI.JavaTypes, 18 | Androidapi.JNIBridge, 19 | Androidapi.JNI.os, 20 | Androidapi.JNI.Media; 21 | 22 | type 23 | // ===== Forward declarations ===== 24 | 25 | JVibrationEffect = interface; // API 26 - android.os.VibrationEffect 26 | JVibrator = interface; // API 1 - android.os.Vibrator 27 | 28 | 29 | // ===== Interface declarations ===== 30 | 31 | JVibrationEffectClass = interface(JObjectClass) 32 | ['{4110B371-A3E8-44F5-8D38-0BFA6A70337E}'] 33 | function _GetDEFAULT_AMPLITUDE: Integer; cdecl; 34 | function _GetEFFECT_CLICK: Integer; cdecl; 35 | function _GetEFFECT_DOUBLE_CLICK: Integer; cdecl; 36 | function _GetEFFECT_HEAVY_CLICK: Integer; cdecl; 37 | function _GetEFFECT_TICK: Integer; cdecl; 38 | function _GetCREATOR: JParcelable_Creator; cdecl; 39 | function createOneShot(milliseconds: Int64; amplitude: Integer): JVibrationEffect; cdecl; // API 26 40 | function createPredefined(effectId: Integer): JVibrationEffect; cdecl; // API 29 41 | function createWaveform(timings: TJavaArray; amplitudes: TJavaArray; repeat_: Integer) 42 | : JVibrationEffect; cdecl; overload; // API 26 43 | function createWaveform(timings: TJavaArray; repeat_: Integer): JVibrationEffect; cdecl; overload; // API 26 44 | property DEFAULT_AMPLITUDE: Integer read _GetDEFAULT_AMPLITUDE; // API 26 45 | property EFFECT_CLICK: Integer read _GetEFFECT_CLICK; // API 29 46 | property EFFECT_DOUBLE_CLICK: Integer read _GetEFFECT_DOUBLE_CLICK; // API 29 47 | property EFFECT_HEAVY_CLICK: Integer read _GetEFFECT_HEAVY_CLICK; // API 29 48 | property EFFECT_TICK: Integer read _GetEFFECT_TICK; // API 29 49 | property CREATOR: JParcelable_Creator read _GetCREATOR; // API 26 50 | end; 51 | 52 | [JavaSignature('android/os/VibrationEffect')] 53 | JVibrationEffect = interface(JObject) 54 | ['{8DD0B73D-5B00-4C34-ABE0-1AE371FDA048}'] 55 | function describeContents: Integer; cdecl; // API 26 56 | end; 57 | 58 | TJVibrationEffect = class(TJavaGenericImport) 59 | end; 60 | 61 | JVibratorClass = interface(JObjectClass) 62 | ['{D7C021F4-5A57-4831-8258-B97C4E63B61B}'] 63 | end; 64 | 65 | [JavaSignature('android/os/Vibrator')] 66 | JVibrator = interface(JObject) 67 | ['{51BBB5B3-ED3F-46C2-89D2-B14FBF46A2F7}'] 68 | procedure cancel; cdecl; // API 1 69 | function hasAmplitudeControl: Boolean; cdecl; // API 26 70 | function hasVibrator: Boolean; cdecl; // API 11 71 | procedure vibrate(milliseconds: Int64); cdecl; overload; // (API 1) Deprecated API 26 72 | procedure vibrate(vibe: JVibrationEffect); cdecl; overload; // API 26 73 | procedure vibrate(pattern: TJavaArray; repeat_: Integer); cdecl; overload; // (API 1) Deprecated API 26 74 | procedure vibrate(pattern: TJavaArray; repeat_: Integer; attributes: JAudioAttributes); cdecl; overload; 75 | // (API 21) Deprecated API 26 76 | procedure vibrate(vibe: JVibrationEffect; attributes: JAudioAttributes); cdecl; overload; // API 26 77 | procedure vibrate(milliseconds: Int64; attributes: JAudioAttributes); cdecl; overload; // (API 21) Deprecated API 26 78 | end; 79 | 80 | TJVibrator = class(TJavaGenericImport) 81 | end; 82 | 83 | implementation 84 | 85 | procedure RegisterTypes; 86 | begin 87 | TRegTypes.RegisterType('Androidapi.JNI.os.Vibration.JVibrationEffect', 88 | TypeInfo(Androidapi.JNI.os.Vibration.JVibrationEffect)); 89 | TRegTypes.RegisterType('Androidapi.JNI.os.Vibration.JVibrator', TypeInfo(Androidapi.JNI.os.Vibration.JVibrator)); 90 | end; 91 | 92 | initialization 93 | 94 | RegisterTypes; 95 | 96 | end. 97 | -------------------------------------------------------------------------------- /Vibrator/class/uVibratorHelper.pas: -------------------------------------------------------------------------------- 1 | { ********************************************************************* 2 | * 3 | * Autor: Efimov A.A. 4 | * E-mail: infocean@gmail.com 5 | * GitHub: https://github.com/AndrewEfimov 6 | * Permissions: "android.permission.VIBRATE" 7 | * Platform (API 19+): Android 4.4.2 - 10 8 | * IDE: Delphi 10.1/10.2/10.3 (Berlin/Tokyo/Rio) 9 | * 10 | ******************************************************************** } 11 | unit uVibratorHelper; 12 | 13 | interface 14 | 15 | uses 16 | Androidapi.Helpers, Androidapi.JNI.Os, 17 | Androidapi.JNI.GraphicsContentViewText, Androidapi.JNIBridge, 18 | System.SysUtils, Androidapi.JNI.Os.Vibration; 19 | 20 | type 21 | TJavaArrayHelper = class 22 | public 23 | class function ArrayStrToJavaArrayInt64(const ASource: array of string): TJavaArray; 24 | class function ArrayInt64ToJavaArrayInt64(const ASource: array of Int64): TJavaArray; 25 | end; 26 | 27 | TVibratorHelper = class(TObject) 28 | private 29 | class var FSDK_INT: Integer; 30 | class var FJVibrator: JVibrator; 31 | class constructor Create; 32 | public 33 | /// Turn the vibrator off. 34 | class procedure cancel; 35 | /// Check whether the hardware has a vibrator. 36 | class function hasVibrator: Boolean; 37 | /// Vibrate constantly for the specified period of time. 38 | class procedure vibrate(const AMilliseconds: Int64); overload; 39 | /// Vibrate with a given pattern. 40 | class procedure vibrate(const APattern: TJavaArray; const ARepeat: Integer); overload; 41 | class procedure vibrate(const APattern: array of Int64; const ARepeat: Integer); overload; 42 | class procedure vibrate(const APattern: array of string; const ARepeat: Integer); overload; 43 | end; 44 | 45 | implementation 46 | 47 | { TJavaArrayHelper } 48 | 49 | class function TJavaArrayHelper.ArrayInt64ToJavaArrayInt64(const ASource: array of Int64): TJavaArray; 50 | var 51 | I: Integer; 52 | begin 53 | Result := TJavaArray.Create(Length(ASource)); 54 | for I := Low(ASource) to High(ASource) do 55 | Result.Items[I] := ASource[I]; 56 | end; 57 | 58 | class function TJavaArrayHelper.ArrayStrToJavaArrayInt64(const ASource: array of string): TJavaArray; 59 | var 60 | I: Integer; 61 | begin 62 | Result := TJavaArray.Create(Length(ASource)); 63 | for I := Low(ASource) to High(ASource) do 64 | Result.Items[I] := ASource[I].ToInt64; 65 | end; 66 | 67 | { TVibrator } 68 | 69 | class procedure TVibratorHelper.cancel; 70 | begin 71 | if hasVibrator then 72 | FJVibrator.cancel; 73 | end; 74 | 75 | class constructor TVibratorHelper.Create; 76 | begin 77 | FSDK_INT := TJBuild_VERSION.JavaClass.SDK_INT; 78 | FJVibrator := TJVibrator.Wrap(TAndroidHelper.Context.getSystemService(TJContext.JavaClass.VIBRATOR_SERVICE)) 79 | end; 80 | 81 | class function TVibratorHelper.hasVibrator: Boolean; 82 | begin 83 | Result := (FJVibrator <> nil) and FJVibrator.hasVibrator; 84 | end; 85 | 86 | class procedure TVibratorHelper.vibrate(const AMilliseconds: Int64); 87 | begin 88 | if hasVibrator then 89 | if FSDK_INT >= 26 then 90 | FJVibrator.vibrate(TJVibrationEffect.JavaClass.createOneShot(AMilliseconds, 91 | TJVibrationEffect.JavaClass.DEFAULT_AMPLITUDE)) 92 | else 93 | FJVibrator.vibrate(AMilliseconds); 94 | end; 95 | 96 | class procedure TVibratorHelper.vibrate(const APattern: array of string; const ARepeat: Integer); 97 | begin 98 | TVibratorHelper.vibrate(TJavaArrayHelper.ArrayStrToJavaArrayInt64(APattern), ARepeat); 99 | end; 100 | 101 | class procedure TVibratorHelper.vibrate(const APattern: array of Int64; const ARepeat: Integer); 102 | begin 103 | TVibratorHelper.vibrate(TJavaArrayHelper.ArrayInt64ToJavaArrayInt64(APattern), ARepeat); 104 | end; 105 | 106 | // pattern: an array of longs of times for which to turn the vibrator on or off. 107 | // repeat: the index into pattern at which to repeat, or -1 if you don't want to repeat. 108 | // array pattern(pause and vibrate in milliseconds): [pause, vibrate, pause, ... , vibrate, pause] 109 | class procedure TVibratorHelper.vibrate(const APattern: TJavaArray; const ARepeat: Integer); 110 | begin 111 | if hasVibrator then 112 | if FSDK_INT >= 26 then 113 | FJVibrator.vibrate(TJVibrationEffect.JavaClass.createWaveform(APattern, ARepeat)) 114 | else 115 | FJVibrator.vibrate(APattern, ARepeat); 116 | end; 117 | 118 | end. 119 | -------------------------------------------------------------------------------- /WifiTestAPI/AndroidManifest.template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | <%uses-permission%> 11 | 12 | 22 | 23 | <%provider%> 24 | <%application-meta-data%> 25 | <%uses-libraries%> 26 | <%services%> 27 | 29 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | <%activity%> 42 | <%receivers%> 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /WifiTestAPI/FMXWifiTestAPI.dpr: -------------------------------------------------------------------------------- 1 | program FMXWifiTestAPI; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | Form.Main in 'Form.Main.pas' {FormMain}, 7 | uUniversalReceiver in 'class\uUniversalReceiver.pas'; 8 | 9 | {$R *.res} 10 | 11 | begin 12 | Application.Initialize; 13 | Application.CreateForm(TFormMain, FormMain); 14 | Application.Run; 15 | end. 16 | -------------------------------------------------------------------------------- /WifiTestAPI/FMXWifiTestAPI.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {B17836B6-190F-4F9F-A5D3-583CB0C423F3} 4 | 19.2 5 | FMX 6 | True 7 | Debug 8 | Android 9 | 32787 10 | Application 11 | FMXWifiTestAPI.dpr 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Base 39 | true 40 | 41 | 42 | true 43 | Cfg_1 44 | true 45 | true 46 | 47 | 48 | true 49 | Cfg_1 50 | true 51 | true 52 | 53 | 54 | true 55 | Cfg_1 56 | true 57 | true 58 | 59 | 60 | true 61 | Base 62 | true 63 | 64 | 65 | true 66 | Cfg_2 67 | true 68 | true 69 | 70 | 71 | true 72 | Cfg_2 73 | true 74 | true 75 | 76 | 77 | .\$(Platform)\$(Config) 78 | .\$(Platform)\$(Config) 79 | false 80 | false 81 | false 82 | false 83 | false 84 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 85 | true 86 | true 87 | true 88 | true 89 | true 90 | true 91 | true 92 | true 93 | $(BDS)\bin\delphi_PROJECTICON.ico 94 | $(BDS)\bin\delphi_PROJECTICNS.icns 95 | FMXWifiTestAPI 96 | 97 | 98 | DBXSqliteDriver;RESTComponents;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;FGXNative.Extension.Zint;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) 99 | package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= 100 | Debug 101 | true 102 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_36x36.png 103 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_48x48.png 104 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png 105 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_96x96.png 106 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_144x144.png 107 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_192x192.png 108 | $(BDS)\bin\Artwork\Android\FM_SplashImage_426x320.png 109 | $(BDS)\bin\Artwork\Android\FM_SplashImage_470x320.png 110 | $(BDS)\bin\Artwork\Android\FM_SplashImage_640x480.png 111 | $(BDS)\bin\Artwork\Android\FM_SplashImage_960x720.png 112 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_24x24.png 113 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png 114 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_48x48.png 115 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png 116 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_96x96.png 117 | android-support-v4.dex.jar;cloud-messaging.dex.jar;com-google-android-gms.play-services-ads-base.17.2.0.dex.jar;com-google-android-gms.play-services-ads-identifier.16.0.0.dex.jar;com-google-android-gms.play-services-ads-lite.17.2.0.dex.jar;com-google-android-gms.play-services-ads.17.2.0.dex.jar;com-google-android-gms.play-services-analytics-impl.16.0.8.dex.jar;com-google-android-gms.play-services-analytics.16.0.8.dex.jar;com-google-android-gms.play-services-base.16.0.1.dex.jar;com-google-android-gms.play-services-basement.16.2.0.dex.jar;com-google-android-gms.play-services-gass.17.2.0.dex.jar;com-google-android-gms.play-services-identity.16.0.0.dex.jar;com-google-android-gms.play-services-maps.16.1.0.dex.jar;com-google-android-gms.play-services-measurement-base.16.4.0.dex.jar;com-google-android-gms.play-services-measurement-sdk-api.16.4.0.dex.jar;com-google-android-gms.play-services-stats.16.0.1.dex.jar;com-google-android-gms.play-services-tagmanager-v4-impl.16.0.8.dex.jar;com-google-android-gms.play-services-tasks.16.0.1.dex.jar;com-google-android-gms.play-services-wallet.16.0.1.dex.jar;com-google-firebase.firebase-analytics.16.4.0.dex.jar;com-google-firebase.firebase-common.16.1.0.dex.jar;com-google-firebase.firebase-iid-interop.16.0.1.dex.jar;com-google-firebase.firebase-iid.17.1.1.dex.jar;com-google-firebase.firebase-measurement-connector.17.0.1.dex.jar;com-google-firebase.firebase-messaging.17.5.0.dex.jar;fmx.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar 118 | 119 | 120 | DBXSqliteDriver;RESTComponents;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;bindcompfmx;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;FGXNative.Extension.Zint;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage) 121 | package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= 122 | Debug 123 | true 124 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_36x36.png 125 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_48x48.png 126 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png 127 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_96x96.png 128 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_144x144.png 129 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_192x192.png 130 | $(BDS)\bin\Artwork\Android\FM_SplashImage_426x320.png 131 | $(BDS)\bin\Artwork\Android\FM_SplashImage_470x320.png 132 | $(BDS)\bin\Artwork\Android\FM_SplashImage_640x480.png 133 | $(BDS)\bin\Artwork\Android\FM_SplashImage_960x720.png 134 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_24x24.png 135 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png 136 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_48x48.png 137 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png 138 | $(BDS)\bin\Artwork\Android\FM_NotificationIcon_96x96.png 139 | android-support-v4.dex.jar;cloud-messaging.dex.jar;com-google-android-gms.play-services-ads-base.17.2.0.dex.jar;com-google-android-gms.play-services-ads-identifier.16.0.0.dex.jar;com-google-android-gms.play-services-ads-lite.17.2.0.dex.jar;com-google-android-gms.play-services-ads.17.2.0.dex.jar;com-google-android-gms.play-services-analytics-impl.16.0.8.dex.jar;com-google-android-gms.play-services-analytics.16.0.8.dex.jar;com-google-android-gms.play-services-base.16.0.1.dex.jar;com-google-android-gms.play-services-basement.16.2.0.dex.jar;com-google-android-gms.play-services-gass.17.2.0.dex.jar;com-google-android-gms.play-services-identity.16.0.0.dex.jar;com-google-android-gms.play-services-maps.16.1.0.dex.jar;com-google-android-gms.play-services-measurement-base.16.4.0.dex.jar;com-google-android-gms.play-services-measurement-sdk-api.16.4.0.dex.jar;com-google-android-gms.play-services-stats.16.0.1.dex.jar;com-google-android-gms.play-services-tagmanager-v4-impl.16.0.8.dex.jar;com-google-android-gms.play-services-tasks.16.0.1.dex.jar;com-google-android-gms.play-services-wallet.16.0.1.dex.jar;com-google-firebase.firebase-analytics.16.4.0.dex.jar;com-google-firebase.firebase-common.16.1.0.dex.jar;com-google-firebase.firebase-iid-interop.16.0.1.dex.jar;com-google-firebase.firebase-iid.17.1.1.dex.jar;com-google-firebase.firebase-measurement-connector.17.0.1.dex.jar;com-google-firebase.firebase-messaging.17.5.0.dex.jar;fmx.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar 140 | 141 | 142 | DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;bindcompvclsmp;emsclientfiredac;tethering;svnui;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;FGXNative.Externals;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;emsedge;fmx;FireDACIBDriver;fmxdae;vcledge;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;FGXNative.Core;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;bindcompvclwinx;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;soaprtl;DbxCommonDriver;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;FGXNative.Extension.Zint;bindcomp;appanalytics;DBXInformixDriver;LockBox3DR;IndyIPClient;bindcompvcl;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 143 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 144 | Debug 145 | true 146 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 147 | 1033 148 | $(BDS)\bin\default_app.manifest 149 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 150 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 151 | 152 | 153 | DBXSqliteDriver;RESTComponents;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;bindcompvclsmp;emsclientfiredac;tethering;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;DBXOracleDriver;inetdb;emsedge;fmx;FireDACIBDriver;fmxdae;vcledge;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;bindcompvclwinx;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;soaprtl;DbxCommonDriver;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;emsserverresource;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;LockBox3DR;IndyIPClient;bindcompvcl;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 154 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 155 | Debug 156 | true 157 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 158 | 1033 159 | $(BDS)\bin\default_app.manifest 160 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 161 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 162 | 163 | 164 | DEBUG;$(DCC_Define) 165 | true 166 | false 167 | true 168 | true 169 | true 170 | 171 | 172 | false 173 | false 174 | false 175 | false 176 | false 177 | true 178 | true 179 | 1 180 | #000000 181 | false 182 | 183 | 184 | false 185 | true 186 | PerMonitorV2 187 | 188 | 189 | true 190 | PerMonitorV2 191 | 192 | 193 | false 194 | RELEASE;$(DCC_Define) 195 | 0 196 | 0 197 | 198 | 199 | true 200 | PerMonitorV2 201 | 202 | 203 | true 204 | PerMonitorV2 205 | 206 | 207 | 208 | MainSource 209 | 210 | 211 |
FormMain
212 | fmx 213 |
214 | 215 | 216 | Cfg_2 217 | Base 218 | 219 | 220 | Base 221 | 222 | 223 | Cfg_1 224 | Base 225 | 226 |
227 | 228 | Delphi.Personality.12 229 | Application 230 | 231 | 232 | 233 | FMXWifiTestAPI.dpr 234 | 235 | 236 | Microsoft Office 2000 Sample Automation Server Wrapper Components 237 | Microsoft Office XP Sample Automation Server Wrapper Components 238 | 239 | 240 | 241 | 242 | 243 | ic_notification.png 244 | true 245 | 246 | 247 | 248 | 249 | ic_launcher.png 250 | true 251 | 252 | 253 | 254 | 255 | ic_launcher.png 256 | true 257 | 258 | 259 | 260 | 261 | splash_image.png 262 | true 263 | 264 | 265 | 266 | 267 | splash_image.png 268 | true 269 | 270 | 271 | 272 | 273 | splash_image.png 274 | true 275 | 276 | 277 | 278 | 279 | ic_notification.png 280 | true 281 | 282 | 283 | 284 | 285 | ic_launcher.png 286 | true 287 | 288 | 289 | 290 | 291 | libFMXWifiTestAPI.so 292 | true 293 | 294 | 295 | 296 | 297 | classes.dex 298 | true 299 | 300 | 301 | 302 | 303 | true 304 | 305 | 306 | 307 | 308 | true 309 | 310 | 311 | 312 | 313 | true 314 | 315 | 316 | 317 | 318 | FMXWifiTestAPI.exe 319 | true 320 | 321 | 322 | 323 | 324 | ic_notification.png 325 | true 326 | 327 | 328 | 329 | 330 | true 331 | 332 | 333 | 334 | 335 | libFMXWifiTestAPI.so 336 | true 337 | 338 | 339 | 340 | 341 | ic_launcher.png 342 | true 343 | 344 | 345 | 346 | 347 | true 348 | 349 | 350 | 351 | 352 | true 353 | 354 | 355 | 356 | 357 | libFMXWifiTestAPI.so 358 | true 359 | 360 | 361 | 362 | 363 | splash_image.png 364 | true 365 | 366 | 367 | 368 | 369 | ic_notification.png 370 | true 371 | 372 | 373 | 374 | 375 | true 376 | 377 | 378 | 379 | 380 | true 381 | 382 | 383 | 384 | 385 | ic_launcher.png 386 | true 387 | 388 | 389 | 390 | 391 | ic_launcher.png 392 | true 393 | 394 | 395 | 396 | 397 | ic_notification.png 398 | true 399 | 400 | 401 | 402 | 403 | styles.xml 404 | true 405 | 406 | 407 | 408 | 409 | true 410 | 411 | 412 | 413 | 414 | 1 415 | 416 | 417 | Contents\MacOS 418 | 1 419 | 420 | 421 | 0 422 | 423 | 424 | 425 | 426 | classes 427 | 1 428 | 429 | 430 | classes 431 | 1 432 | 433 | 434 | 435 | 436 | res\xml 437 | 1 438 | 439 | 440 | res\xml 441 | 1 442 | 443 | 444 | 445 | 446 | library\lib\armeabi-v7a 447 | 1 448 | 449 | 450 | 451 | 452 | library\lib\armeabi 453 | 1 454 | 455 | 456 | library\lib\armeabi 457 | 1 458 | 459 | 460 | 461 | 462 | library\lib\armeabi-v7a 463 | 1 464 | 465 | 466 | 467 | 468 | library\lib\mips 469 | 1 470 | 471 | 472 | library\lib\mips 473 | 1 474 | 475 | 476 | 477 | 478 | library\lib\armeabi-v7a 479 | 1 480 | 481 | 482 | library\lib\arm64-v8a 483 | 1 484 | 485 | 486 | 487 | 488 | library\lib\armeabi-v7a 489 | 1 490 | 491 | 492 | 493 | 494 | res\drawable 495 | 1 496 | 497 | 498 | res\drawable 499 | 1 500 | 501 | 502 | 503 | 504 | res\values 505 | 1 506 | 507 | 508 | res\values 509 | 1 510 | 511 | 512 | 513 | 514 | res\values-v21 515 | 1 516 | 517 | 518 | res\values-v21 519 | 1 520 | 521 | 522 | 523 | 524 | res\values 525 | 1 526 | 527 | 528 | res\values 529 | 1 530 | 531 | 532 | 533 | 534 | res\drawable 535 | 1 536 | 537 | 538 | res\drawable 539 | 1 540 | 541 | 542 | 543 | 544 | res\drawable-xxhdpi 545 | 1 546 | 547 | 548 | res\drawable-xxhdpi 549 | 1 550 | 551 | 552 | 553 | 554 | res\drawable-xxxhdpi 555 | 1 556 | 557 | 558 | res\drawable-xxxhdpi 559 | 1 560 | 561 | 562 | 563 | 564 | res\drawable-ldpi 565 | 1 566 | 567 | 568 | res\drawable-ldpi 569 | 1 570 | 571 | 572 | 573 | 574 | res\drawable-mdpi 575 | 1 576 | 577 | 578 | res\drawable-mdpi 579 | 1 580 | 581 | 582 | 583 | 584 | res\drawable-hdpi 585 | 1 586 | 587 | 588 | res\drawable-hdpi 589 | 1 590 | 591 | 592 | 593 | 594 | res\drawable-xhdpi 595 | 1 596 | 597 | 598 | res\drawable-xhdpi 599 | 1 600 | 601 | 602 | 603 | 604 | res\drawable-mdpi 605 | 1 606 | 607 | 608 | res\drawable-mdpi 609 | 1 610 | 611 | 612 | 613 | 614 | res\drawable-hdpi 615 | 1 616 | 617 | 618 | res\drawable-hdpi 619 | 1 620 | 621 | 622 | 623 | 624 | res\drawable-xhdpi 625 | 1 626 | 627 | 628 | res\drawable-xhdpi 629 | 1 630 | 631 | 632 | 633 | 634 | res\drawable-xxhdpi 635 | 1 636 | 637 | 638 | res\drawable-xxhdpi 639 | 1 640 | 641 | 642 | 643 | 644 | res\drawable-xxxhdpi 645 | 1 646 | 647 | 648 | res\drawable-xxxhdpi 649 | 1 650 | 651 | 652 | 653 | 654 | res\drawable-small 655 | 1 656 | 657 | 658 | res\drawable-small 659 | 1 660 | 661 | 662 | 663 | 664 | res\drawable-normal 665 | 1 666 | 667 | 668 | res\drawable-normal 669 | 1 670 | 671 | 672 | 673 | 674 | res\drawable-large 675 | 1 676 | 677 | 678 | res\drawable-large 679 | 1 680 | 681 | 682 | 683 | 684 | res\drawable-xlarge 685 | 1 686 | 687 | 688 | res\drawable-xlarge 689 | 1 690 | 691 | 692 | 693 | 694 | res\values 695 | 1 696 | 697 | 698 | res\values 699 | 1 700 | 701 | 702 | 703 | 704 | 1 705 | 706 | 707 | Contents\MacOS 708 | 1 709 | 710 | 711 | 0 712 | 713 | 714 | 715 | 716 | Contents\MacOS 717 | 1 718 | .framework 719 | 720 | 721 | Contents\MacOS 722 | 1 723 | .framework 724 | 725 | 726 | 0 727 | 728 | 729 | 730 | 731 | 1 732 | .dylib 733 | 734 | 735 | 1 736 | .dylib 737 | 738 | 739 | 1 740 | .dylib 741 | 742 | 743 | Contents\MacOS 744 | 1 745 | .dylib 746 | 747 | 748 | Contents\MacOS 749 | 1 750 | .dylib 751 | 752 | 753 | 0 754 | .dll;.bpl 755 | 756 | 757 | 758 | 759 | 1 760 | .dylib 761 | 762 | 763 | 1 764 | .dylib 765 | 766 | 767 | 1 768 | .dylib 769 | 770 | 771 | Contents\MacOS 772 | 1 773 | .dylib 774 | 775 | 776 | Contents\MacOS 777 | 1 778 | .dylib 779 | 780 | 781 | 0 782 | .bpl 783 | 784 | 785 | 786 | 787 | 0 788 | 789 | 790 | 0 791 | 792 | 793 | 0 794 | 795 | 796 | 0 797 | 798 | 799 | 0 800 | 801 | 802 | Contents\Resources\StartUp\ 803 | 0 804 | 805 | 806 | Contents\Resources\StartUp\ 807 | 0 808 | 809 | 810 | 0 811 | 812 | 813 | 814 | 815 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 816 | 1 817 | 818 | 819 | 820 | 821 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 822 | 1 823 | 824 | 825 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 826 | 1 827 | 828 | 829 | 830 | 831 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 832 | 1 833 | 834 | 835 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 836 | 1 837 | 838 | 839 | 840 | 841 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 842 | 1 843 | 844 | 845 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 846 | 1 847 | 848 | 849 | 850 | 851 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 852 | 1 853 | 854 | 855 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 856 | 1 857 | 858 | 859 | 860 | 861 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 862 | 1 863 | 864 | 865 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 866 | 1 867 | 868 | 869 | 870 | 871 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 872 | 1 873 | 874 | 875 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 876 | 1 877 | 878 | 879 | 880 | 881 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 882 | 1 883 | 884 | 885 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 886 | 1 887 | 888 | 889 | 890 | 891 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 892 | 1 893 | 894 | 895 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 896 | 1 897 | 898 | 899 | 900 | 901 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 902 | 1 903 | 904 | 905 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 906 | 1 907 | 908 | 909 | 910 | 911 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 912 | 1 913 | 914 | 915 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 916 | 1 917 | 918 | 919 | 920 | 921 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 922 | 1 923 | 924 | 925 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 926 | 1 927 | 928 | 929 | 930 | 931 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 932 | 1 933 | 934 | 935 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 936 | 1 937 | 938 | 939 | 940 | 941 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 942 | 1 943 | 944 | 945 | ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 946 | 1 947 | 948 | 949 | 950 | 951 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 952 | 1 953 | 954 | 955 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 956 | 1 957 | 958 | 959 | 960 | 961 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 962 | 1 963 | 964 | 965 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 966 | 1 967 | 968 | 969 | 970 | 971 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 972 | 1 973 | 974 | 975 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 976 | 1 977 | 978 | 979 | 980 | 981 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 982 | 1 983 | 984 | 985 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 986 | 1 987 | 988 | 989 | 990 | 991 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 992 | 1 993 | 994 | 995 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 996 | 1 997 | 998 | 999 | 1000 | 1001 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1002 | 1 1003 | 1004 | 1005 | ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1006 | 1 1007 | 1008 | 1009 | 1010 | 1011 | 1 1012 | 1013 | 1014 | 1 1015 | 1016 | 1017 | 1018 | 1019 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1020 | 1 1021 | 1022 | 1023 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1024 | 1 1025 | 1026 | 1027 | 1028 | 1029 | ..\ 1030 | 1 1031 | 1032 | 1033 | ..\ 1034 | 1 1035 | 1036 | 1037 | 1038 | 1039 | 1 1040 | 1041 | 1042 | 1 1043 | 1044 | 1045 | 1 1046 | 1047 | 1048 | 1049 | 1050 | ..\$(PROJECTNAME).launchscreen 1051 | 64 1052 | 1053 | 1054 | ..\$(PROJECTNAME).launchscreen 1055 | 64 1056 | 1057 | 1058 | 1059 | 1060 | 1 1061 | 1062 | 1063 | 1 1064 | 1065 | 1066 | 1 1067 | 1068 | 1069 | 1070 | 1071 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1072 | 1 1073 | 1074 | 1075 | 1076 | 1077 | ..\ 1078 | 1 1079 | 1080 | 1081 | ..\ 1082 | 1 1083 | 1084 | 1085 | 1086 | 1087 | Contents 1088 | 1 1089 | 1090 | 1091 | Contents 1092 | 1 1093 | 1094 | 1095 | 1096 | 1097 | Contents\Resources 1098 | 1 1099 | 1100 | 1101 | Contents\Resources 1102 | 1 1103 | 1104 | 1105 | 1106 | 1107 | library\lib\armeabi-v7a 1108 | 1 1109 | 1110 | 1111 | library\lib\arm64-v8a 1112 | 1 1113 | 1114 | 1115 | 1 1116 | 1117 | 1118 | 1 1119 | 1120 | 1121 | 1 1122 | 1123 | 1124 | 1 1125 | 1126 | 1127 | Contents\MacOS 1128 | 1 1129 | 1130 | 1131 | Contents\MacOS 1132 | 1 1133 | 1134 | 1135 | 0 1136 | 1137 | 1138 | 1139 | 1140 | library\lib\armeabi-v7a 1141 | 1 1142 | 1143 | 1144 | 1145 | 1146 | 1 1147 | 1148 | 1149 | 1 1150 | 1151 | 1152 | 1153 | 1154 | Assets 1155 | 1 1156 | 1157 | 1158 | Assets 1159 | 1 1160 | 1161 | 1162 | 1163 | 1164 | Assets 1165 | 1 1166 | 1167 | 1168 | Assets 1169 | 1 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | True 1185 | True 1186 | True 1187 | True 1188 | 1189 | 1190 | 12 1191 | 1192 | 1193 | 1194 | 1195 |
1196 | -------------------------------------------------------------------------------- /WifiTestAPI/Form.Main.fmx: -------------------------------------------------------------------------------- 1 | object FormMain: TFormMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'FormMain' 5 | ClientHeight = 480 6 | ClientWidth = 367 7 | FormFactor.Width = 320 8 | FormFactor.Height = 480 9 | FormFactor.Devices = [Desktop] 10 | OnCreate = FormCreate 11 | OnDestroy = FormDestroy 12 | DesignerMasterStyle = 3 13 | object TabControl1: TTabControl 14 | Align = Client 15 | Size.Width = 367.000000000000000000 16 | Size.Height = 480.000000000000000000 17 | Size.PlatformDefault = False 18 | TabHeight = 49.000000000000000000 19 | TabIndex = 0 20 | TabOrder = 0 21 | TabPosition = PlatformDefault 22 | Sizes = ( 23 | 367s 24 | 431s 25 | 367s 26 | 431s) 27 | object tiInfo: TTabItem 28 | CustomIcon = < 29 | item 30 | end> 31 | IsSelected = True 32 | Size.Width = 183.000000000000000000 33 | Size.Height = 49.000000000000000000 34 | Size.PlatformDefault = False 35 | StyleLookup = '' 36 | TabOrder = 0 37 | Text = 'Info' 38 | ExplicitSize.cx = 171.000000000000000000 39 | ExplicitSize.cy = 49.000000000000000000 40 | object mInfo: TMemo 41 | Touch.InteractiveGestures = [Pan, LongTap, DoubleTap] 42 | DataDetectorTypes = [] 43 | ReadOnly = True 44 | Align = Client 45 | Size.Width = 367.000000000000000000 46 | Size.Height = 381.000000000000000000 47 | Size.PlatformDefault = False 48 | TabOrder = 0 49 | Viewport.Width = 359.000000000000000000 50 | Viewport.Height = 373.000000000000000000 51 | end 52 | object Layout1: TLayout 53 | Align = Bottom 54 | Position.Y = 381.000000000000000000 55 | Size.Width = 367.000000000000000000 56 | Size.Height = 50.000000000000000000 57 | Size.PlatformDefault = False 58 | TabOrder = 1 59 | object sbGetInfo: TSpeedButton 60 | Align = Client 61 | Size.Width = 367.000000000000000000 62 | Size.Height = 48.000000000000000000 63 | Size.PlatformDefault = False 64 | Text = 'Get Info' 65 | OnClick = sbGetInfoClick 66 | end 67 | end 68 | end 69 | object tiScanResult: TTabItem 70 | CustomIcon = < 71 | item 72 | end> 73 | IsSelected = False 74 | Size.Width = 184.000000000000000000 75 | Size.Height = 49.000000000000000000 76 | Size.PlatformDefault = False 77 | StyleLookup = '' 78 | TabOrder = 0 79 | Text = 'Scan result' 80 | ExplicitSize.cx = 171.000000000000000000 81 | ExplicitSize.cy = 49.000000000000000000 82 | object lvScanResults: TListView 83 | ItemAppearanceClassName = 'TListItemAppearance' 84 | ItemEditAppearanceClassName = 'TListItemShowCheckAppearance' 85 | HeaderAppearanceClassName = 'TListHeaderObjects' 86 | FooterAppearanceClassName = 'TListHeaderObjects' 87 | AllowSelection = False 88 | Align = Client 89 | Size.Width = 367.000000000000000000 90 | Size.Height = 381.000000000000000000 91 | Size.PlatformDefault = False 92 | TabOrder = 0 93 | ItemAppearanceObjects.ItemObjects.Accessory.Visible = False 94 | CanSwipeDelete = False 95 | ShowSelection = False 96 | SearchAlwaysOnTop = False 97 | end 98 | object Layout2: TLayout 99 | Align = Bottom 100 | Position.Y = 381.000000000000000000 101 | Size.Width = 367.000000000000000000 102 | Size.Height = 50.000000000000000000 103 | Size.PlatformDefault = False 104 | TabOrder = 1 105 | object sbScan: TSpeedButton 106 | Align = Client 107 | Size.Width = 367.000000000000000000 108 | Size.Height = 48.000000000000000000 109 | Size.PlatformDefault = False 110 | Text = 'Scan' 111 | OnClick = sbScanClick 112 | end 113 | end 114 | end 115 | end 116 | end 117 | -------------------------------------------------------------------------------- /WifiTestAPI/Form.Main.pas: -------------------------------------------------------------------------------- 1 | unit Form.Main; 2 | 3 | interface 4 | 5 | uses 6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl, FMX.Layouts, FMX.Controls.Presentation, 8 | FMX.StdCtrls, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo, FMX.ListView.Types, FMX.ListView.Appearances, 9 | FMX.ListView.Adapters.Base, FMX.ListView, 10 | uUniversalReceiver, 11 | Androidapi.JNI.GraphicsContentViewText, 12 | Androidapi.JNI.JavaTypes, 13 | Androidapi.JNI.Net,// or Androidapi.JNI.net.wifi (https://github.com/AndrewEfimov/Wrappers/blob/master/Androidapi.JNI.net.wifi.pas) 14 | Androidapi.Helpers, 15 | Androidapi.JNI, 16 | Androidapi.JNIBridge, 17 | System.Permissions; 18 | 19 | type 20 | TFormMain = class(TForm) 21 | TabControl1: TTabControl; 22 | Layout1: TLayout; 23 | tiInfo: TTabItem; 24 | tiScanResult: TTabItem; 25 | sbGetInfo: TSpeedButton; 26 | sbScan: TSpeedButton; 27 | mInfo: TMemo; 28 | lvScanResults: TListView; 29 | Layout2: TLayout; 30 | procedure FormCreate(Sender: TObject); 31 | procedure FormDestroy(Sender: TObject); 32 | procedure sbGetInfoClick(Sender: TObject); 33 | procedure sbScanClick(Sender: TObject); 34 | private const 35 | PermissionAccessFineLocation = 'android.permission.ACCESS_FINE_LOCATION'; 36 | private 37 | FBroadcastReceiver: TBroadcastReceiver; 38 | FWifiManager: JWifiManager; 39 | procedure OnReceiveScanResults(context: JContext; intent: JIntent); 40 | procedure LoadWifiInfo(Sender: TObject; const APermissions: TArray; 41 | const AGrantResults: TArray); 42 | procedure StartScan(Sender: TObject; const APermissions: TArray; 43 | const AGrantResults: TArray); 44 | public 45 | { Public declarations } 46 | end; 47 | 48 | var 49 | FormMain: TFormMain; 50 | 51 | implementation 52 | 53 | {$R *.fmx} 54 | 55 | { TFormMain } 56 | 57 | function DecToIpv4(const AValue: Cardinal): string; 58 | begin 59 | // LITTLE_ENDIAN 60 | Result := Format('%d.%d.%d.%d', [AValue and $FF, (AValue shr 8) and $FF, (AValue shr 16) and $FF, AValue shr 24]); 61 | end; 62 | 63 | procedure TFormMain.FormCreate(Sender: TObject); 64 | begin 65 | FBroadcastReceiver := TBroadcastReceiver.Create; 66 | FBroadcastReceiver.OnReceive := OnReceiveScanResults; 67 | FBroadcastReceiver.IntentFilterAdd([TJWifiManager.JavaClass.SCAN_RESULTS_AVAILABLE_ACTION]); 68 | FBroadcastReceiver.registerReceiver; 69 | 70 | FWifiManager := TJWifiManager.Wrap(TAndroidHelper.context.getSystemService(TJContext.JavaClass.WIFI_SERVICE)); 71 | end; 72 | 73 | procedure TFormMain.FormDestroy(Sender: TObject); 74 | begin 75 | FBroadcastReceiver.Free; 76 | end; 77 | 78 | procedure TFormMain.LoadWifiInfo(Sender: TObject; const APermissions: TArray; 79 | const AGrantResults: TArray); 80 | var 81 | WifiInfo: JWifiInfo; 82 | begin 83 | if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then 84 | begin 85 | WifiInfo := FWifiManager.getConnectionInfo(); 86 | 87 | mInfo.Lines.Clear; 88 | mInfo.Lines.Add('BSSID: ' + TAndroidHelper.JStringToString(WifiInfo.getBSSID)); 89 | mInfo.Lines.Add('HiddenSSID: ' + WifiInfo.getHiddenSSID.ToString); 90 | mInfo.Lines.Add('IpAddress: ' + DecToIpv4(WifiInfo.getIpAddress)); 91 | mInfo.Lines.Add('LinkSpeed: ' + WifiInfo.getLinkSpeed.ToString + ' Mbps'); 92 | mInfo.Lines.Add('MacAddress: ' + TAndroidHelper.JStringToString(WifiInfo.getMacAddress)); 93 | mInfo.Lines.Add('NetworkId: ' + WifiInfo.getNetworkId.ToString); 94 | mInfo.Lines.Add('Rssi: ' + WifiInfo.getRssi.ToString + ' dBm'); 95 | mInfo.Lines.Add('SSID: ' + TAndroidHelper.JStringToString(WifiInfo.getSSID)); 96 | mInfo.Lines.Add('SupplicantState: ' + TAndroidHelper.JStringToString(WifiInfo.getSupplicantState.ToString)); 97 | end; 98 | end; 99 | 100 | procedure TFormMain.OnReceiveScanResults(context: JContext; intent: JIntent); 101 | var 102 | ScanResults: JList; 103 | I: Integer; 104 | ScanResultsItem: JScanResult; 105 | LItem: TListViewItem; 106 | begin 107 | if intent.getBooleanExtra(TJWifiManager.JavaClass.EXTRA_RESULTS_UPDATED, False) then 108 | begin 109 | ScanResults := FWifiManager.getScanResults(); 110 | 111 | lvScanResults.Items.Clear; 112 | lvScanResults.BeginUpdate; 113 | try 114 | for I := 0 to ScanResults.size - 1 do 115 | begin 116 | ScanResultsItem := TJScanResult.Wrap(ScanResults.get(I)); 117 | 118 | LItem := lvScanResults.Items.Add; 119 | LItem.Text := TAndroidHelper.JStringToString(ScanResultsItem.SSID); 120 | end; 121 | finally 122 | lvScanResults.EndUpdate; 123 | end; 124 | end; 125 | end; 126 | 127 | procedure TFormMain.sbGetInfoClick(Sender: TObject); 128 | begin 129 | PermissionsService.RequestPermissions([PermissionAccessFineLocation], LoadWifiInfo); 130 | end; 131 | 132 | procedure TFormMain.sbScanClick(Sender: TObject); 133 | begin 134 | PermissionsService.RequestPermissions([PermissionAccessFineLocation], StartScan); 135 | end; 136 | 137 | procedure TFormMain.StartScan(Sender: TObject; const APermissions: TArray; 138 | const AGrantResults: TArray); 139 | begin 140 | if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then 141 | FWifiManager.StartScan(); 142 | end; 143 | 144 | end. 145 | -------------------------------------------------------------------------------- /WifiTestAPI/class/uUniversalReceiver.pas: -------------------------------------------------------------------------------- 1 | { ********************************************************************* 2 | * 3 | * Autor: Efimov A.A. 4 | * E-mail: infocean@gmail.com 5 | * GitHub: https://github.com/AndrewEfimov/ 6 | * Platform: only Android (API 21+) 7 | * Created: 24.05.2016 8 | * Updated: 22.03.2022 9 | * 10 | ******************************************************************** } 11 | 12 | unit uUniversalReceiver; 13 | 14 | interface 15 | 16 | uses 17 | Androidapi.JNI.Embarcadero, Androidapi.JNIBridge, Androidapi.Helpers, Androidapi.JNI.GraphicsContentViewText, 18 | Androidapi.JNI.JavaTypes; 19 | 20 | type 21 | 22 | TBroadcastReceiveEvent = procedure(context: JContext; intent: JIntent) of object; 23 | 24 | TBroadcastReceiver = class; 25 | 26 | TListener = class(TJavaLocal, JFMXBroadcastReceiverListener) 27 | strict private 28 | FOwner: TBroadcastReceiver; 29 | public 30 | constructor Create(AOwner: TBroadcastReceiver); 31 | procedure OnReceive(context: JContext; intent: JIntent); cdecl; 32 | end; 33 | 34 | TBroadcastReceiver = class 35 | strict private 36 | FListener: TListener; 37 | FBroadcastReceiver: JFMXBroadcastReceiver; 38 | FIntentFilter: JIntentFilter; 39 | FOnReceive: TBroadcastReceiveEvent; 40 | public 41 | property OnReceive: TBroadcastReceiveEvent read FOnReceive write FOnReceive; 42 | constructor Create; 43 | destructor Destroy; override; 44 | procedure IntentFilterAdd(const AValue: JString); overload; 45 | procedure IntentFilterAdd(const AValues: array of JString); overload; 46 | procedure registerReceiver; 47 | procedure unregisterReceiver; 48 | end; 49 | 50 | implementation 51 | 52 | { TListener } 53 | 54 | constructor TListener.Create(AOwner: TBroadcastReceiver); 55 | begin 56 | inherited Create; 57 | FOwner := AOwner; 58 | end; 59 | 60 | procedure TListener.OnReceive(context: JContext; intent: JIntent); 61 | begin 62 | if Assigned(FOwner.OnReceive) then 63 | FOwner.OnReceive(context, intent); 64 | end; 65 | 66 | { TBroadcastReceiver } 67 | 68 | constructor TBroadcastReceiver.Create; 69 | begin 70 | inherited Create; 71 | 72 | FListener := TListener.Create(Self); 73 | FBroadcastReceiver := TJFMXBroadcastReceiver.JavaClass.init(FListener); 74 | 75 | FIntentFilter := TJIntentFilter.Create; 76 | end; 77 | 78 | destructor TBroadcastReceiver.Destroy; 79 | begin 80 | unregisterReceiver; 81 | 82 | inherited Destroy; 83 | end; 84 | 85 | procedure TBroadcastReceiver.IntentFilterAdd(const AValues: array of JString); 86 | var 87 | I: Integer; 88 | begin 89 | for I := 0 to Length(AValues) - 1 do 90 | IntentFilterAdd(AValues[I]); 91 | end; 92 | 93 | procedure TBroadcastReceiver.IntentFilterAdd(const AValue: JString); 94 | begin 95 | if not AValue.isEmpty then 96 | FIntentFilter.addAction(AValue); 97 | end; 98 | 99 | procedure TBroadcastReceiver.registerReceiver; 100 | begin 101 | if FIntentFilter.countActions > 0 then 102 | TAndroidHelper.Context.registerReceiver(FBroadcastReceiver, FIntentFilter); 103 | end; 104 | 105 | procedure TBroadcastReceiver.unregisterReceiver; 106 | begin 107 | if FBroadcastReceiver <> nil then 108 | TAndroidHelper.Context.unregisterReceiver(FBroadcastReceiver); 109 | 110 | FBroadcastReceiver := nil; 111 | FListener.Free; 112 | FIntentFilter := nil; 113 | end; 114 | 115 | end. 116 | --------------------------------------------------------------------------------