Jump to content

Minox

Members
  • Content Count

    26
  • Joined

  • Last visited

Posts posted by Minox


  1. I also encountered the same problem, I solved it by replacing the code:

    Ad := '"' + DosyaAdi(Uri) + '" '

    with

    If RequestCode<>Dizin_Agaci_Ac
       Then Ad := '"' + DosyaAdi(Uri) + '" '
       Else Ad := TPath.GetFileName(JStringToString(uri.getPath));

    in the "OnActivityResult" procedure, but it still doesn't work, even if you give consent you can't read the files. I tried with the "Download" folder and I only get the folders contained therein.

     

    • Like 1

  2. 38 minutes ago, David Heffernan said:

    I'm honestly not sure why this topic is still open. It's the exception mask. Something is changing it. You don't have complete control over it. Other modules that are loaded into your process can change it. It's quite messy. It's been covered ad nauseum here, Borland forums, SO, etc.

     

    Run this program to demonstrate how the different exception masks influence behaviour:

     

    
    {$APPTYPE CONSOLE}
    
    uses
      System.SysUtils,
      System.Math;
    
    procedure Main;
    var
      x, y: Double;
      Mask: TArithmeticExceptionMask;
    begin
      x := 0;
      y := 0;
    
      Mask := GetExceptionMask;
    
      SetExceptionMask(Mask + [exInvalidOp]);
      Writeln(x / y);
    
      SetExceptionMask(Mask - [exInvalidOp]);
      Writeln(x / y);
    end;
    
    begin
      try
        Main;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
      Readln;
    end.

     

    For your scenario, when NaN is produced, clearly invalidop is masked. When the exception is raised it is unmasked.

     

     

    The problem is that if the division results in "NAN", no exception is raised, so at runtime the error cannot be detected.


  3. I had a similar problem with android, I solved it by trying to convert the result to string and then to number, so I modified your code a bit, but I can't test it with "NAN":

    procedure TForm2.Button1Click(Sender: TObject);
    var
      V1, V2, V3: Variant;
      I1, I2: Integer;
      S1    : String;
    begin
      V1 := 0;
      V2 := 0;
    
      Try V3 := V1 / V2;
          Except
          V3 := -1;
      End;
    
      Try S1 := FloatToStr(V3);
          StrToFloat(S1);
          Except
          V3 := -1;
      End;
    
      If V3=-1
         Then ShowMessage('Division by zero')
         Else ShowMessage(V3);
    
      I1 := 0;
      I2 := 0;
      ShowMessage(FloatToStr(I1 / I2));
    end;

     


  4. 6 hours ago, MikeZ87 said:

    That actually does make it A LOT easier. Thanks!

     

    I was going to ask you - after playing with this a little bit, I notice that the main text (ie: the text of the itemindex item) is BIG (like the style,) but the drop-down text is still tiny. How can I change the font size of the drop down text?

     

    Thanks again A MILLION!!!

     

    - Mike

     

    Have you tried changing the "Scale" property? in some cases it may be fine


  5. If your intention is to open the explorer automatically in a specific location, I don't think it's possible to do it with the system one. Third-party ones do it instead, but I've never faced the problem. This session could be a good start to understand if there is a possibility to do it.

    • Like 1

  6. I use this:

    uses Androidapi.JNI.GraphicsContentViewText,
         Androidapi.Helpers,
         System.Messaging,
         Androidapi.JNI.Net,
         Androidapi.JNI.App,
    
    PROCEDURE TForm1.GetFileBrowser;
          VAR Intent  : JIntent;
              ReqCode : Integer;
        BEGIN
              ReqCode := 1000;
    
              Intent := TJIntent.Create;
    
              Intent.setType(StringToJString('*/*'));
              Intent.setAction(TJIntent.JavaClass.ACTION_GET_CONTENT);
              Intent.putExtra(TJIntent.JavaClass.EXTRA_ALLOW_MULTIPLE,true);
    
              TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification,
                              procedure(const Sender   : TObject;
                                        const aMessage : TMessage)
                                    VAR msgRES : TMessageResultNotification;
                                  begin
                                        msgRES:= TMessageResultNotification(aMessage);
    
                                        If msgRES.RequestCode=ReqCode Then
                                           if (msgRES.ResultCode=TJActivity.JavaClass.RESULT_OK) Then
                                               Begin
    
                                               URIfileTrn := msgRES.Value.getData(); //URI sing file selez
    
                                               If URIfileTrn=Nil Then //multiselez
                                                  ClipDataF := msgRES.Value.getClipData;
    
                                               End;
                                  end);
    
              TAndroidHelper.Activity.startActivityForResult(Intent, ReqCode);
        END;

    and then via thread process the URI

    • Like 1

  7. you're declaring the same variable 10 times, I don't think it's possible the way you mean, you could alternatively use a record type, and then call it in an array, like:
     

    type
      myRec = Record
              myVar : String[20];
              End;
    
    [...]
    
    var
      ArrRec : Array Of myRec;
    
    [...]
    
    procedure Sample(const AFixedArray: TSomeFixedArray);
    begin
      SetLength(ArrRec,10);
    
      for var I = 0 to 10 do
      begin
        ArrRec[I].myVar := 'xyz'+I.ToString;
        // do something
      end
    end

     


  8. If you have the rights to access the "DCIM/MyFolder" folder, you could build a simple browser (via "System.IOUtils.TDirectory.GetFiles") yourself and display the files contained in a list. Or launch an "Intent" with "ACTION_GET_CONTENT", to open the system app

    • Like 1

  9. Handle it like a data store? In the sense of creating a record for the first file where some fields point to the second file, so when you order the first, to read in the second file you just need to read the pointer.


  10. Hi all, I have a code to maximize and minimize screen brightness for android app, which works fine in 32bit, but not in 64bit. Here is the code:

     

    USES Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers;
    
    
    procedure TForm1.Button1Click(Sender: TObject); //min
          VAR appParam : JWindowManager_LayoutParams;
        begin
              appParam := TAndroidHelper.Activity.getWindow.getAttributes;
              appParam.screenBrightness := TJWindowManager_LayoutParams.JavaClass.BRIGHTNESS_OVERRIDE_OFF;
              TAndroidHelper.Activity.getWindow.setAttributes(appParam);
        end;
    
    procedure TForm1.Button2Click(Sender: TObject); //max
          VAR appParam : JWindowManager_LayoutParams;
        begin
              appParam := TAndroidHelper.Activity.getWindow.getAttributes;
              appParam.screenBrightness := TJWindowManager_LayoutParams.JavaClass.BRIGHTNESS_OVERRIDE_FULL;
              TAndroidHelper.Activity.getWindow.setAttributes(appParam);
        end;
    
    procedure TForm1.Button3Click(Sender: TObject); //norm
          VAR appParam : JWindowManager_LayoutParams;
        begin
              appParam := TAndroidHelper.Activity.getWindow.getAttributes;
              appParam.screenBrightness := TJWindowManager_LayoutParams.JavaClass.BRIGHTNESS_OVERRIDE_NONE;
              TAndroidHelper.Activity.getWindow.setAttributes(appParam);
        end;
    
    

     

    I don't understand why it doesn't work, do I have to ask permission for the 64bit app and manually change the brightness?


  11. Hello everyone,
    Do you know if it is possible to insert a link in your app, which points to the Google Play Store page, to view the list of your applications?


  12. try like this

     

    procedure TForm1.TrackBar1Change(Sender: TObject);
    begin
      ShowValue;
    
      //ScaledLayout1.Scale.X := TrackBar1.Value;
      //ScaledLayout1.Scale.Y := TrackBar1.Value;
    
      ScaledLayout1.BeginUpdate;
      ScaledLayout1.Width := ScaledLayout1.OriginalWidth * TrackBar1.Value;
      ScaledLayout1.Height := ScaledLayout1.OriginalHeight * TrackBar1.Value;
      ScaledLayout1.EndUpdate;
    
      //ScaledLayout1.RecalcAbsoluteNow;
      //ScaledLayout1.RecalcSize;
    end;

     


  13. From the latest versions of Android, to read the notifications the user must manually approve this choice, therefore when starting the app you have to open the notification authorization list and let him select it.
    To achieve this, as far as I understand, you need to set the "android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" permission in the Manifest file (I do this in the project options), as described here: NotificationListenerService, and then at runtime open the permissions page to ask the user to activate them, using this entry: Settings Here a procedure in java: notificationlistenerservice I know my approach is wrong, but i don't understand where. For example, when I asked permission for brightness in other applications, I used the same approach, and it worked.

     


  14. This is because the actual size of the rectangle does not change. Try inserting the main rectangle in a Layout of the same size, and when you work with the TrackBar change the size of the Layout appropriately. Or resize the main rectangle directly, instead of acting on the "Scale" property

×