6
votes

Please follow the steps below:

  1. Create New Firemonkey Moblie Application
  2. Add TGeustureManager component to the Form
  3. Add 2 TButton components to the Form

    • Button1.Text: "Button1: Do something..."
    • Button2.Text: "Button2: Exit Application..."

    The application should appear like this

  4. Double click on Button2 Component and write the following code for OnClick Event:

    procedure TForm1.Button2Click(Sender: TObject);
    begin
      if MessageDlg('Are you sure you want to Exit?', TMsgDlgType.mtWarning,
              [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
        SharedActivity.finish;
    end;
    
  5. Run the application in debug mode.
  6. on the device, click the button 2, then click yes to the popped up message. An exception will appear:

    enter image description here

Why is this exception raised?

I thought it is related to unused TGeustureManager component. but NO it is NOT:

  1. If you open the Location Demo project that comes with Delphi xe5.
  2. Add TButton component to Location Label as shown in the image below: enter image description here
  3. Add the same code as above to OnClick Event.
  4. Run the application, and click on Button5, you will get the same exception.

Is this a bug should I report? or am I doing something wrong?

5
I have precisely the same exception all over the place, not related to terminating my app. Sad I cannot find much info about it. Only happens on anything in Firemonkey which is NOT Windows. Windows works fine, all others fail. Some of it I figured out (for example I needed to use generics TList<> rather than the old TList) but now the XSuperObject library does this when parsing a file (which is a correctly formatted JSON file in the correct location). - Jerry Dodge

5 Answers

1
votes

Possibly that you are killing the activity that is running, before its execution flow has been exhausted, thereby causing problems. Much like freeing a form in a form method....

What happens if you replace:

SharedActivity.finish

with:

uses
  FMX.Helpers.Android;
...
CallOnUIThread(procedure begin SharedActivity.finish end);

[ Typed from memory, so may need some tweaking ]

1
votes

I have contacted Embarcadero for this issue.

They said that it is because TApplication.Terminate is not yet implemented in FireMonkey platform for mobile.

They open a ticket to implement TApplication.Terminate in nex hot fix.

Let's hope that will not take ages.

0
votes

if you want only to close application un can try this:

case MessageDlg('Close Application?', System.UITypes.TMsgDlgType.mtInformation,
    [
      System.UITypes.TMsgDlgBtn.mbYes,
      System.UITypes.TMsgDlgBtn.mbNo
    ], 0) of
    { Detect which button was pushed and show a different message }
    mrNo:
      showmessage('');
    mrYes:
      halt;
  end;
0
votes

I have the same error on a very simple Location test app, it happens when setting text on a label. The label was set to auto size, and when I changed it to a static size the error went away.

Delphi XE6, line 681 in FMX.TextLayout.GPU

I am using a Samsung S4 phone.

procedure TForm_StayTogether.LocationSensor1LocationChanged(Sender: TObject;
  const OldLocation, NewLocation: TLocationCoord2D);
begin
  DistLabel.Text:= FloatToStr(LocationSensor1.Distance);
  AccLabel.Text:= FloatToStr(LocationSensor1.Accuracy);
  LatLabel.Text:= FloatToStr(NewLocation.Latitude);
  LonLabel.Text:= FloatToStr(NewLocation.Longitude);
end;
-4
votes

I've just experienced something similar, a very tiny app with little code giving this same error (Segmentation fault 11) every single time I quit the app on the Android device (Galaxy Note 2 in my case).

For what it's worth, the problem disappeared when I went to the Stylebook I had earlier put on the form and cleared it. I think I had earlier copied that Stylebook from another test unit.

Mike