Jump to content

at3s

Members
  • Content Count

    66
  • Joined

  • Last visited

Posts posted by at3s


  1. 11 hours ago, Rollo62 said:

    Yes, the location is called asynchronously.

     

    I also would not stress the system directly in FormCreate, with the activation of Location, where it is still loading and initializating.
    Better to do that at a later time, maybe FormShow, or even better, manually controlled on demand by your own code only.

     

    I'm not sure if you asked for PermissionRequest correctly, because I cannot see something similar like this in your code.

    The result should be in mainUI thread, but to ensure that this is true you can use ForceQueue, to protect this against mysterious situations.

    I know that Android systems might forgive many of such issues in debug mode, but clearly is at high risk to fail in release and PlayStore.

    
    procedure Tfrm.FormShow(Sender: TObject);
    begin
        DoLocationActivate;
    end;
    
    procedure Tfrm.DoLocationActivate;
    begin
        TPermissionsService.DefaultService.RequestPermissions(
            [LPermissionLocationF, LPermissionLocationC]
            // PermissionResult
          , procedure ( const APermissions: TClassicStringDynArray;  const AGrantResults: TClassicPermissionStatusDynArray )
            begin
                if      (     ( Length( AGrantResults )  <> 2                           )
                          or (        ( AGrantResults[0] <> TPermissionStatus.Granted ) ) 
                          or (        ( AGrantResults[1] <> TPermissionStatus.Granted ) ) 
                        ) then
                begin
                    exit;  //user doesnt grant access
                end;
    
                TThread.ForceQueue(   // this should not be necessary, but just to ensure that Active := True is really called in the main thread only
                    procedure
                    begin
                        LocationSensor.Active := True;
                    end );
            
            end );
    end;

     

    Yes, there is PermissionRequest in the code, but I did not provide it here.

    It executes before a screen showing.

     

    Your code works fine and it's more elegant and correct than my trick with the OnLocationChanged event, thanks for an answer.


  2. I have a screen with the: 

    LocationSensor: TLocationSensor;

    And code:

    procedure Tfrm.FormCreate(Sender: TObject);
    begin
      LocationSensor.Active := True;
    end;
    
    procedure Tfrm.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      LocationSensor.Active := False;
      Action := TCloseAction.caFree;
    end;
    
    procedure ShowLocation();
    var
      mapPosition: TMapCoordinate;
    begin
      frm := Tfrm.Create(Application);
      try
        mapPosition := TMapCoordinate.Create(frm.LocationSensor.Sensor.Latitude, frm.LocationSensor.Sensor.Longitude);
    
        ShowMessage(FloatToStr(frm.LocationSensor.Sensor.Latitude) + ' | ' + FloatToStr(frm.LocationSensor.Sensor.Longitude));
      finally
        frm.Show;
        frm.BringToFront;
      end;
    end;

    When I call ShowLocation(); in Android 12, it returns 'NaN | NaN' first time, after that each calling returns correct coordinates.

     

    Is it a known issue or did I miss something?


  3. 22 minutes ago, Dalija Prasnikar said:

    iOS does not support terminating application, so Delphi does not have that support either.  If Delphi previously implemented Terminate on iOS it was most likely removed as such functionality would cause rejection on the AppStore. See https://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application

    Yup, I already found the source where it raises.

    So how close\hide iOS application using Delphi?

    I'm new with it.

    image.thumb.png.2f2f706b6df8f3c14026e177c15f6773.png


  4. I'm using libssl.so v 1.0.2r in my project and there was not a problem with the Android migration from Delphi 10.4 to 11.2.

    Sure, there are files for Android32 and Android64.


  5. On 2/23/2023 at 2:23 PM, Patrick PREMARTIN said:

    You have a solution, even if you don't have or want to buy a M1/M2 Mac today: you can rent one for few a days at a low cost.

     

    Try https://www.scaleway.com/en/hello-m1/

     

    They rent real Mac mini M1 hosted in a datacenter in Paris (France). You only have to install the softwares you need : Xcode and PAServer.

     

    You have a replay of my webinar (FR) at https://serialstreameur.fr/webinaire-20210304.php with links to written explanations (to translate in your language).

    Unfortunately I got the same error when was trying to build an iOS application on "Apple M1" chip\processor.

    What is wrong with this?

     

    I noticed, when I run a Windows version of this application built in Delphi 11, it required midas.dll.

    It was not when an app was build in Delphi 10.4.

    iOS fault on libmidas.a.

    [DCC Error] E2597 ld: in c:\program files (x86)\embarcadero\studio\22.0\lib\iOSSimARM64\Release\libmidas.a(C:\Projects\Olympus\tp\intermediate\release\lib\midas\iosdevice64\alchemy.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

    Just a notice.


  6. 1 hour ago, Patrick PREMARTIN said:

    Hi

    Has your Mac a M1/M2 processor or an "old" Intel model ?

    Unfortunately it's an Intel - 2.3GHz Dual-Core Intel Core i5.

     

    1 hour ago, beytullah said:

    Do you run successfully on IOS Device? (Not Simulator)

     

    I were working an project 7 years ago. One library not worked on IOS Simulator and not build project. But I runned on IOS device. The project built successfully. 

     

    You should try run your project on IOS Device.

    Yes, the project built (but not ran) fine on "iOS Device 64-bit" platform.

    The issue is - I've not connected an iPhone.

    Because it's my first iOS project and even was not sure I'll be able to finish it for iOS platform.

    So I was thought a simulator shall be enough.

     


  7. image.thumb.png.4a68573248dfb58751b4986419119d9c.png

     

    I'm trying to build my FMX iOS application.

    When I've selected iPhone, the project built fine.

    I'm not able to debug an application, because I do not have iPhone attached to my Mac machine.

     

    But an error has been occurred when I've selected simulator (see a screen shot):

    [DCC Error] E2597 ld: in c:\program files (x86)\embarcadero\studio\22.0\lib\iOSSimARM64\Release\libmidas.a(C:\Projects\Olympus\tp\intermediate\release\lib\midas\iosdevice64\alchemy.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

    Any idea how to fix this?

     


  8. I have a FireMonkey application which works fine in an Android.

    Now I want to build it in iOS.

    But the problem is, I did never it before.

    Can someone explain what exactly I have to do?

    F.e. Mac ot not, if 'yes' - what configuration, OS, iPhone or enough is simulator etc?

    Simple things for someone with the skills...


  9. 7 hours ago, Cristian Peța said:

    If you don't have the documentation then at least follow what that article says clearly: " This is because low-level programmers, such as those who designed the ESC/POS language, tend to blur the lines between data types: it’s all bytes at the end of the day."

    You need to write binary data. Simply don't put binary data in String and convert using TEncoding.ASCII.GetBytes().

     

    This won't help you. But if you want to know I used TBytes.

    As you can see in my sample, I don't send a string to the POS printer but rather TBytes.

    Probably a string type of AValue parameter of SendString procedure twice confusing you.

    Sure, it AValue is not properly populated, SendString procedure shall send something weird.

    But I got an image as output on printer, but it's just cutting by horizontal lines.

    And this Lazarus implementation of Nicholas Piasecki's code doesn't work for me as well.


  10. 14 hours ago, David Heffernan said:

    Do you have a specification for what these s printer expects to receive? 

    I used a lot of specification for ESC\POS printer.

    Actually I tried to make my code working in RawBT application (something like virtual ESC\POS printer) and now I'm trying to use GOOJPRT PT-210 device.

    I did not find a specification for this model of printer.

     

    but I require more general solution to be able to print a receipt from my Android application.


  11. 15 hours ago, Cristian Peța said:

    You are using examples from others that doesn't work or doesn't work in your case.

    Maybe it's time to read the documentation of that printer, understand it and do it right.

     

    From what I understood reading a little Nicholas Piasecki's article is that you need to send binary data. Not ASCII.

    And from your code it's clear that you need (like in Nicholas Piasecki's article) a monochrome, one bit per pixel image. In top-bottom and right-left order. This is binary data. A sort of simplified PCX graphic format (long time ago I wrote a little procedure to save TBitmap to PCX format).

     

    Your don't need SendString(AValue: String) function. Use directly LSockect.SendData() instead. And don't use String but TBytes like LSockect.SendData() is expecting.

     

    Actually Delphi code above should do exactly what Nicholas Piasecki did in his article using C#.

     

    Can you please send me in PM your procedure of saving TBitmap to PCX format?


  12. On 2/15/2021 at 3:36 PM, Alex40 said:

    I am glad to tell you that we finally managed to fix the issue with the missing libs for the Android Service. 

     

    The Service.template.java file was causing this problem. It is generated when service is built.

     

    The file was outdated, below you will find the difference in the files:

     

    NEW:

    @Override
    public void onCreate() {
    libraryName = "lib" + baseLibraryName + ".so";
    super.onCreate();
    ProxyService.onCreate(this, libraryName);

     

    OLD:

    @Override
    public void onCreate() {
    libraryName = getApplicationInfo().nativeLibraryDir + "/lib" + baseLibraryName + ".so";
    super.onCreate();
    ProxyService.onCreate(this, libraryName);

     

    To be sure you have the latest version of the template java file, named "SERVICENAME.template.java" - when you upgrade to higher version of Delphi, just delete the file from the Service project folder and build the Service again, so the Delphi Compiler generates the latest one. If you have custom settings there, you will have to include them again in the new file!

     

    Regarding the OpenSSL libraries issue - I haven't tried to set their lib path the same way as the service does, but as far as they work in the Document path, I am fine with that.

     

    You can see as well the difference between the old and the new file in the screenshot below:
     

    image_2021_02_15T08_41_58_434Z.png

    Probably I have similar issue - application is freezing on splash screen in devices with the 64-bit system.

    I'm using libssl.so v 1.0.2r.

    The path is defined in an application in this way:

    IdOpenSSLSetLibPath(TPath.Combine(TPath.GetDocumentsPath, 'lib/arm64'));

    And file deployes in .\assets\internal\lib\arm64 folder.

    Where can I find that "SERVICENAME.template.java" file?

    It seems, I have not it.

×