Help on lamw components lazarus / 43-Android ---------------------------------------------------------------------- ramsetev · 2021-09-13 15:37 Hi, I am new to this forum, I am pleased to find that it is possible to develop android apps using the beloved Pascal. I met him about 30 years ago with the TurboPascal, and then continued a bit in Delphi. Now I'm curious to try in Lazarus and especially with the possibility of developing android apps. Here is my question for you: I have a small problem with the jcOpenMapView component: I do not get a rendering of the map but only a gray grid. Maybe it doesn't work anymore? ---------------------------------------------------------------------- jmpessoa · 2021-09-13 17:38 Hi,  ramsetev! Welcome! What about "demos":  "AppJCenterOpenStreetMapDemo1"  and "AppJCenterOpenStreetMapDemo2"  ?? Its [yet] works? ---------------------------------------------------------------------- loaded · 2021-09-14 17:00 Quote from: jmpessoa on September 13, 2021, 07:38:41 pm "AppJCenterOpenStreetMapDemo1"  and "AppJCenterOpenStreetMapDemo2"  ?? Its [yet] works? Master jmpessoa, I tested it voluntarily, they work fine ---------------------------------------------------------------------- ramsetev · 2021-09-15 07:14 Yes, it works fine, I didn't ask for writing permission, my apologies and thanks for the support. Where can I find some explanation on   the "request code" for the RequestRuntimePermission procedure? And a demo fo JLocation component? Many Thanks ---------------------------------------------------------------------- loaded · 2021-09-15 19:09 Firstly; Regarding RequestRuntimePermission, I think the following code contains the necessary explanation. You can also examine the web page about what is happening on the Android side. ​https://developer.androi d.com/guide/topics/security/permissions#normal-dangerous Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...   ​//ht tps://developer.android.com/guide/topics/security/permissions#normal- dangerous ​if IsRuntimePermissionNeed() then   // that is, target API >= 23 ​begin    ​ShowMessage('RequestRuntimePermission....');    ​Self .RequestRuntimePermission('android.permission.ACCESS_FINE_LOCATION', 1003); //from AndroodManifest.xml ​end;.... procedure TAndroidModule1.AndroidModule1RequestPermissionResult( ​Sender: TObject; requestCode: integer; manifestPermission: string; ​grantResult: TManifestPermissionResult);begin   ​case requestCode of    ​1003:begin   //android.permission.ACCESS_FINE_LOCATION              ​if grantResult = PERMISSION_GRANTED  then              ​begin                  ​ShowMessage(manifestPermission + ' :: Success! Permission grant!!! ' )              ​end              ​else  //PERMISSION_DENIED              ​ShowMessage(manifestPermission + '   :: Sorry... permission not grant... ' )          ​end; ​end;end; Demo examples about JLocation; You can find it as ............\lazandroidmodulewizard- master\demos\GUI\AppLocationDemo1  and AppLocationDemo2 However, you must have a Google Developer Account to Run this example. then you should get a Google API Key that includes support for Geolocation and Maps Static, and then activate billing. If I am wrong, I will be glad if the masters correct me. Respects. ---------------------------------------------------------------------- ramsetev · 2021-09-17 14:11 no way to use gps or coarse location? ---------------------------------------------------------------------- jmpessoa · 2021-09-17 17:27 Quoteno way to use gps or coarse location? Where? ---------------------------------------------------------------------- ramsetev · 2021-09-21 06:04 I understand the jlocation component uses the localization offered by google, with the related costs. Is there no way to use the GPS or approximate positioning directly from the smartphone instead? ---------------------------------------------------------------------- loaded · 2021-09-21 16:12 Of course, it is possible to use GPS and very easily; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {hint: Pascal files location: ...\AppLAMWProject1\jni }unit unit1; {$mode delphi} interface uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Classes, SysUtils, AndroidWidget, Laz_And_Controls, location;  type   { TAndroidModule1 }   TAndroidModule1 = class(jForm)    jEditText1: jEditText;    jEditText2: jEditText;    jLocation1: jLocation;    procedure AndroidModule1ActivityResume(Sender: TObject);    procedure AndroidModule1JNIPrompt(Sender: TObject);    procedure AndroidModule1RequestPermissionResult(Sender: TObject;      requestCode: integer; manifestPermission: string;      grantResult: TManifestPermissionResult);    procedure jLocation1GpsStatusChanged(Sender: TObject;      countSatellites: integer; gpsStatusEvent: TGpsStatusEvent);    procedure jLocation1LocationChanged(Sender: TObject; latitude: double;      longitude: double; altitude: double; address: string);    procedure P_gps_opener;  private    {private declarations}  public    {public declarations}  end; var  AndroidModule1: TAndroidModule1;  RRPermissionGps:Boolean=false;implementation  {$R *.lfm}   { TAndroidModule1 } procedure TAndroidModule1.P_gps_opener;begin  if not jLocation1.IsGPSProvider then  begin    ShowMessage('GPS OFF');    jLocation1.ShowLocationSouceSettings();  end  else  begin    ShowMessage('GPS ON');    jLocation1.StartTracker();  end;end; procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);begin  if Self.IsRuntimePermissionNeed() then  begin    Self. RequestRuntimePermission('android.permission.ACCESS_FINE_LOCATION', 7777);  endend; procedure TAndroidModule1.AndroidModule1ActivityResume(Sender: TObject);begin  if RRPermissionGps then P_gps_opener;end; procedure TAndroidModule1.AndroidModule1RequestPermissionResult(  Sender: TObject; requestCode: integer; manifestPermission: string;  grantResult: TManifestPermissionResult);begin    if requestCode = 7777 then  begin     if grantResult = PERMISSION_GRANTED then     begin      RRPermissionGps:=true;        P_gps_opener;     end     else      ShowMessage('Sorry... "android.permission.ACCESS_FINE_LOCATION" DENIED...');  end;end;   procedure TAndroidModule1.jLocation1GpsStatusChanged(Sender: TObject;countSatellites: integer; gpsStatusEvent: TGpsStatusEvent);begin  case gpsStatusEvent of      gpsStopped:begin               end;     gpsStarted: begin                 end;     gpsFirstFix:                 begin                 end;     gpsSatelliteStatus:                 begin                 end;  end;end; procedure TAndroidModule1.jLocation1LocationChanged(Sender: TObject;latitude: double; longitude: double; altitude: double; address: string);begin  jEditText1.Text:=floattostr(latitude);  jEditText2.Text:=floattostr(longitude);end; end. The program has been tested. Good luck with your gps and your way ---------------------------------------------------------------------- ramsetev · 2021-09-23 14:45 Quote from: loaded on September 21, 2021, 06:12:45 pmOf course, it is possible to use GPS and very easily; .... The program has been tested. Good luck with your gps and your way Thank you! ---------------------------------------------------------------------- jmpessoa · 2021-09-23 20:55 Hi, loaded! Please, put your new " jLocation" demo in some "open drive" ... I will commit it  to LAMW github! Thank you! ---------------------------------------------------------------------- loaded · 2021-09-24 15:58 Quote from: jmpessoa on September 23, 2021, 10:55:15 pm Hi, loaded! Please, put your new " jLocation" demo in some "open drive" ... I will commit it  to LAMW github! Thank you! This is an order for me that I will gladly do. Master Jmpessoa  Link to the demo : https://cadplugin.com/other/AppLocationForGpsDemo.rar ---------------------------------------------------------------------- jmpessoa · 2021-09-24 17:35 NEW  "AppLocationForGpsDemo" Added to LAMW GUI demos! Thank you!