Jump to content

Aamgian

Members
  • Content Count

    17
  • Joined

  • Last visited

Posts posted by Aamgian


  1. On 3/20/2021 at 3:39 AM, Remy Lebeau said:

    If the sole purpose of the thread is just to delay a UI notification, then TThread.ForceQueue() would be better, no thread needed at all:

    
    procedure THeaderFooterForm.Button1Click(Sender: TObject);
    begin
      TThread.ForceQueue(nil,
        procedure
        begin
          HeaderLabel.Text := 'My Job';
        end
      );
    end;

     

    The code that I will use is actually a lot more, especially for doing the calculation process and making requests to the server.

    thank you for the advice you give.


  2. 50 minutes ago, Remy Lebeau said:

    The device should not matter, no. This is strictly an RTL error message that TThread.Start() raises if it can't resume a suspended thread, either because the thread is not allowed to resume (e, it is already finished), or the OS failed to resume the thread properly.  Hard to say for sure what is going on without seeing the latest source code for TThread. 

     

    I replaced all CreateAnonynousThread in my project with ITask and all works fine.

    thank you

     

    procedure THeaderFooterForm.Button1Click(Sender: TObject);
    var
     aTask: ITask;
    begin
     aTask := TTask.Create(
       procedure
       begin
         TThread.Synchronize(TThread.Current,
           procedure
           begin
             HeaderLabel.Text := 'My Job';
           end);
       end);
       aTask.Start;
    end;

     


  3. 2 hours ago, Remy Lebeau said:

    I don't have the source for the latest version to look at, but in XE3 (the last version I do have source for), that specific error message only occurs under these conditions:

     

    - (Windows only) calling Start() on a running thread, or a thread that has had Suspend() called on it more than once before Start().

    - calling Start() on a thread that has already finished, but not been destroyed yet

    - calling Start() on a thread created by reading TThread.CurrentThread in a thread context that is not owned by a TThread.

     

    None of those conditions apply to your TThread.CreateAnonynousThread() example.  Calling Start() on such a thread is absolutely the correct thing to do.  So this has to be a bug that Embarcadero has introduced in a recent version and will have to fix.

    I have tried using Samsung and Xiaomi brand devices with SDK 30 but this error does not occur. is there a role for the device in causing this to happen?

    as a note the device with the Vivo brand that I use is the latest release.


  4. Hello,

     

    simple code that I made:

    TThread.CreateAnonymousThread(procedure
      begin
        TThread.Synchronize(nil, procedure
        begin
          HeaderLabel.Text := 'My Job';
        end);
      end).Resume;

    when the target Android 64bit compile, using the application resume runs smoothly.

     

    Meanwhile, if you use Start to call the thread, error message will appear "cannot call start on a running or suspended thread"

    TThread.CreateAnonymousThread(procedure
      begin
        TThread.Synchronize(nil, procedure
        begin
          HeaderLabel.Text := 'My Job';
        end);
      end).Start;

    this case only happened on some android devices target android 64bit, but if the target is 32bit the error message does not appear.

    has anyone experienced something similar? and what is the solution?

     

    device with sdk 30.

     

    Thank you


  5. Thanks Dave, at least the VPN connection on the device can be known

     

    this code work i tested with android 9 and 10.

    function TPlatformConnectivity.IsVPNConnection: Boolean;
    var
      LManager: JConnectivityManager;
      LAllNetworks: TJavaObjectArray<JNetwork>;
      LCapabilities: JNetworkCapabilities;
      I: Integer;
    begin
      Result := False;
      LManager := ConnectivityManager;
      LAllNetworks := LManager.getAllNetworks;
      for I := 0 to LAllNetworks.Length - 1 do
      begin
        LCapabilities := LManager.getNetworkCapabilities(LAllNetworks[I]);
        if (LCapabilities <> nil) and LCapabilities.hasTransport(TJNetworkCapabilities.JavaClass.TRANSPORT_VPN) then
        begin
          Result := True;
          Break;
        end;
      end;
    end;

     

    • Like 2

  6. Hello,

     

    How do I know if there is a VPN connection on the device that is active, because my application will ignore if using VPN?

    I use this code but it doesn't seem to work.

    function TPlatformConnectivity.IsVPNConnection: Boolean;
    var
      LManager: JConnectivityManager;
      LAllNetworks: TJavaObjectArray<JNetwork>;
      LCapabilities: JNetworkCapabilities;
      I: Integer;
    begin
      Result := False;
      LManager := ConnectivityManager;
      LAllNetworks := LManager.getAllNetworks;
      for I := 0 to LAllNetworks.Length - 1 do
      begin
        LCapabilities := LManager.getNetworkCapabilities(LAllNetworks[I]);
        if (LCapabilities <> nil) and LCapabilities.hasCapability(TJNetworkCapabilities.JavaClass.TRANSPORT_VPN) then
        //if (LCapabilities <> nil) and LCapabilities.hasCapability(TJNetworkCapabilities.JavaClass.TRANSPORT_VPN) then
        begin
          Result := True;
          Break;
        end;
      end;
    end;

     

    Thanks You

     


  7. sorry if my question is not clear, my problem is that not all aledit components can be directly above the virtual keyboard when it is showing. if you look at the 28 second video, the aledit component is not where I want it to be.


  8. hi, does anyone use the alcinoe library here?
    I'm making a project using the alcinoe library, I have trouble handling the virtual keyboard when it appears. as seen in the gif file, the code works well only for the bottom 5 components contained in the AlVertScrollBox component. The following is a stub project that I made with additional TFramestand and Kastree libraries.
    Thanks for your help

    vkeyboard.zip


  9. 18 hours ago, Dave Nottage said:

    You'll need to modify the patch in FMX.FontGlyphs.Android.pas to look like this:

    
        NameFont := TPath.Combine(TPath.GetDocumentsPath, CurrentSettings.Family);
        if not CurrentSettings.Style.Weight.IsRegular and TFile.Exists(NameFont + '-Bold.ttf') then
          NameFont := NameFont + '-Bold.ttf'
        else if CurrentSettings.Style.Weight.IsRegular and TFile.Exists(NameFont + '-Regular.ttf') then
          NameFont := NameFont + '-Regular.ttf'
        else
          NameFont := NameFont + '.ttf';

     

    thanks you for you help, but still not work. I decided to leave this font problem in the application that I made.


  10. 3 hours ago, Dave Nottage said:

    Metode yang sama berfungsi baik pada saya dengan Font Awesome. Font apa yang Anda gunakan?

    I use nunito sans font from Google font. I made an application using the third party taltext component alcinoe so that the method could not worked but in android 9 that work fine, after I tried it with the default TText component it worked fine. but the next problem if I use the bold font style then it doesn't work. The following sample file that I made

    true_font.zip


  11. Thank you Dave,

    I am done with the Android code of, now I have not found a reference for iOS. the link above that you provide seems to be a problem with the web emb.


     

    uses
    
    Androidapi.helpers, Androidapi.JNI.GraphicsContentViewText,
    Androidapi.jni.net, Androidapi.JNI.App, Androidapi.JNI.JavaTypes,
    
    
    function FetchSms(sender:string):string;
    var
      cursor: JCursor;
      uri: Jnet_Uri;
      address, msgdatesent, body: string;
      addressidx, msgdatesentidx, bodyidx: integer;
      fMessage: string;
    begin
      uri := StrToJURI('content://sms/inbox');
      cursor := TAndroidHelper.Activity.getContentResolver.query(uri, nil, nil,nil,nil);
      addressidx := cursor.getColumnIndex(StringToJstring('address'));
      msgdatesentidx := cursor.getColumnIndex(StringToJstring('date_sent'));
      bodyidx := cursor.getColumnIndex(StringToJstring('body'));
      cursor.moveToFirst;
      while (cursor.moveToNext) do
      begin
        address := JStringToString(cursor.getString(addressidx));
        msgdatesent := JStringToString(cursor.getString(msgdatesentidx));
        body := JStringToString(cursor.getString(bodyidx));
        if UpperCase(address) = UpperCase(sender) then
        begin
          fMessage := msgdatesent+'-'+address+'-'+body;
          Break
        end;
      end;
      Result := fMessage;
    end;

    of course you must be given READ_SMS  permission.

×