Recent

Author Topic: Help on lamw components  (Read 2560 times)

ramsetev

  • New member
  • *
  • Posts: 5
Help on lamw components
« on: September 13, 2021, 05:37:59 pm »
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

  • Hero Member
  • *****
  • Posts: 1943
Re: Help on lamw components
« Reply #1 on: September 13, 2021, 07:38:41 pm »

Hi,  ramsetev!

Welcome!

What about "demos":

 "AppJCenterOpenStreetMapDemo1"  and "AppJCenterOpenStreetMapDemo2"  ??

Its [yet] works?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

loaded

  • Sr. Member
  • ****
  • Posts: 299
Re: Help on lamw components
« Reply #2 on: September 14, 2021, 07:00:05 pm »
"AppJCenterOpenStreetMapDemo1"  and "AppJCenterOpenStreetMapDemo2"  ??

Its [yet] works?


Master jmpessoa, I tested it voluntarily, they work fine :)

Lazarus V2.0.10 32 Bit + Intel I5 8250U + 12GB RAM + Win 10 Home 64 Bit = red pill
Morpheus: "You take the blue pill...the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill...you stay in Wonderland, and I show you how deep the rabbit hole goes."

ramsetev

  • New member
  • *
  • Posts: 5
Re: Help on lamw components
« Reply #3 on: September 15, 2021, 09:14:09 am »
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
« Last Edit: September 15, 2021, 09:59:48 am by ramsetev »

loaded

  • Sr. Member
  • ****
  • Posts: 299
Re: Help on lamw components
« Reply #4 on: September 15, 2021, 09:09:04 pm »
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.android.com/guide/topics/security/permissions#normal-dangerous
Code: Pascal  [Select][+][-]
  1. ...
  2.    ​//https://developer.android.com/guide/topics/security/permissions#normal-dangerous
  3.  ​if IsRuntimePermissionNeed() then   // that is, target API >= 23
  4.  ​begin
  5.     ​ShowMessage('RequestRuntimePermission....');
  6.     ​Self.RequestRuntimePermission('android.permission.ACCESS_FINE_LOCATION', 1003); //from AndroodManifest.xml
  7.  ​end;
  8. ....
  9.  
  10. procedure TAndroidModule1.AndroidModule1RequestPermissionResult(
  11.  ​Sender: TObject; requestCode: integer; manifestPermission: string;
  12.  ​grantResult: TManifestPermissionResult);
  13. begin
  14.    ​case requestCode of
  15.     ​1003:begin   //android.permission.ACCESS_FINE_LOCATION
  16.               ​if grantResult = PERMISSION_GRANTED  then
  17.               ​begin
  18.                   ​ShowMessage(manifestPermission + ' :: Success! Permission grant!!! ' )
  19.               ​end
  20.               ​else  //PERMISSION_DENIED
  21.                 ​ShowMessage(manifestPermission + '   :: Sorry... permission not grant... ' )
  22.           ​end;
  23.  ​end;
  24. end;
  25.  

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.
Lazarus V2.0.10 32 Bit + Intel I5 8250U + 12GB RAM + Win 10 Home 64 Bit = red pill
Morpheus: "You take the blue pill...the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill...you stay in Wonderland, and I show you how deep the rabbit hole goes."

ramsetev

  • New member
  • *
  • Posts: 5
Re: Help on lamw components
« Reply #5 on: September 17, 2021, 04:11:30 pm »
no way to use gps or coarse location?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1943
Re: Help on lamw components
« Reply #6 on: September 17, 2021, 07:27:58 pm »
Quote
no way to use gps or coarse location?

Where?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

ramsetev

  • New member
  • *
  • Posts: 5
Re: Help on lamw components
« Reply #7 on: September 21, 2021, 08:04:42 am »
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

  • Sr. Member
  • ****
  • Posts: 299
Re: Help on lamw components
« Reply #8 on: September 21, 2021, 06:12:45 pm »
Of course, it is possible to use GPS and very easily;
Code: Pascal  [Select][+][-]
  1. {hint: Pascal files location: ...\AppLAMWProject1\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  10.   cthreads,
  11.   {$ENDIF}{$ENDIF}
  12.   Classes, SysUtils, AndroidWidget, Laz_And_Controls, location;
  13.  
  14. type
  15.  
  16.   { TAndroidModule1 }
  17.  
  18.   TAndroidModule1 = class(jForm)
  19.     jEditText1: jEditText;
  20.     jEditText2: jEditText;
  21.     jLocation1: jLocation;
  22.     procedure AndroidModule1ActivityResume(Sender: TObject);
  23.     procedure AndroidModule1JNIPrompt(Sender: TObject);
  24.     procedure AndroidModule1RequestPermissionResult(Sender: TObject;
  25.       requestCode: integer; manifestPermission: string;
  26.       grantResult: TManifestPermissionResult);
  27.     procedure jLocation1GpsStatusChanged(Sender: TObject;
  28.       countSatellites: integer; gpsStatusEvent: TGpsStatusEvent);
  29.     procedure jLocation1LocationChanged(Sender: TObject; latitude: double;
  30.       longitude: double; altitude: double; address: string);
  31.     procedure P_gps_opener;
  32.   private
  33.     {private declarations}
  34.   public
  35.     {public declarations}
  36.   end;
  37.  
  38. var
  39.   AndroidModule1: TAndroidModule1;
  40.   RRPermissionGps:Boolean=false;
  41. implementation
  42.  
  43. {$R *.lfm}
  44.  
  45.  
  46. { TAndroidModule1 }
  47.  
  48. procedure TAndroidModule1.P_gps_opener;
  49. begin
  50.   if not jLocation1.IsGPSProvider then
  51.   begin
  52.     ShowMessage('GPS OFF');
  53.     jLocation1.ShowLocationSouceSettings();
  54.   end
  55.   else
  56.   begin
  57.     ShowMessage('GPS ON');
  58.     jLocation1.StartTracker();
  59.   end;
  60. end;
  61.  
  62. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
  63. begin
  64.   if Self.IsRuntimePermissionNeed() then
  65.   begin
  66.     Self.RequestRuntimePermission('android.permission.ACCESS_FINE_LOCATION', 7777);
  67.   end
  68. end;
  69.  
  70. procedure TAndroidModule1.AndroidModule1ActivityResume(Sender: TObject);
  71. begin
  72.   if RRPermissionGps then P_gps_opener;
  73. end;
  74.  
  75. procedure TAndroidModule1.AndroidModule1RequestPermissionResult(
  76.   Sender: TObject; requestCode: integer; manifestPermission: string;
  77.   grantResult: TManifestPermissionResult);
  78. begin
  79.     if requestCode = 7777 then
  80.   begin
  81.      if grantResult = PERMISSION_GRANTED then
  82.      begin
  83.         RRPermissionGps:=true;
  84.         P_gps_opener;
  85.      end
  86.      else
  87.         ShowMessage('Sorry... "android.permission.ACCESS_FINE_LOCATION" DENIED...');
  88.   end;
  89. end;
  90.  
  91.  
  92.  
  93. procedure TAndroidModule1.jLocation1GpsStatusChanged(Sender: TObject;countSatellites: integer; gpsStatusEvent: TGpsStatusEvent);
  94. begin
  95.   case gpsStatusEvent of
  96.       gpsStopped:begin
  97.                  end;
  98.      gpsStarted: begin
  99.                  end;
  100.      gpsFirstFix:
  101.                  begin
  102.                  end;
  103.      gpsSatelliteStatus:
  104.                  begin
  105.                  end;
  106.   end;
  107. end;
  108.  
  109. procedure TAndroidModule1.jLocation1LocationChanged(Sender: TObject;latitude: double; longitude: double; altitude: double; address: string);
  110. begin
  111.   jEditText1.Text:=floattostr(latitude);
  112.   jEditText2.Text:=floattostr(longitude);
  113. end;
  114.  
  115. end.

The program has been tested.
Good luck with your gps and your way :)
Lazarus V2.0.10 32 Bit + Intel I5 8250U + 12GB RAM + Win 10 Home 64 Bit = red pill
Morpheus: "You take the blue pill...the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill...you stay in Wonderland, and I show you how deep the rabbit hole goes."

ramsetev

  • New member
  • *
  • Posts: 5
Re: Help on lamw components
« Reply #9 on: September 23, 2021, 04:45:26 pm »
Of 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

  • Hero Member
  • *****
  • Posts: 1943
Re: Help on lamw components
« Reply #10 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!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

loaded

  • Sr. Member
  • ****
  • Posts: 299
Re: Help on lamw components
« Reply #11 on: September 24, 2021, 05:58:38 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



Lazarus V2.0.10 32 Bit + Intel I5 8250U + 12GB RAM + Win 10 Home 64 Bit = red pill
Morpheus: "You take the blue pill...the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill...you stay in Wonderland, and I show you how deep the rabbit hole goes."

jmpessoa

  • Hero Member
  • *****
  • Posts: 1943
Re: Help on lamw components
« Reply #12 on: September 24, 2021, 07:35:27 pm »

NEW  "AppLocationForGpsDemo"

Added to LAMW GUI demos!

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018