问题
Please follow the steps below:
- Create New
Firemonkey Moblie Application - Add
TGeustureManagercomponent to the Form Add 2
TButtoncomponents to the Form- Button1.Text: "Button1: Do something..."
- Button2.Text: "Button2: Exit Application..."

Double click on Button2 Component and write the following code for
OnClickEvent: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;- Run the application in debug mode.
on the device, click the button 2, then click yes to the popped up message. An exception will appear:

Why is this exception raised?
I thought it is related to unused TGeustureManager component. but NO it is NOT:
- If you open the
LocationDemo project that comes with Delphi xe5. - Add
TButtoncomponent toLocationLabel as shown in the image below:
- Add the same code as above to
OnClickEvent. - 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?
回答1:
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 ]
回答2:
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;
回答3:
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.
回答4:
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;
回答5:
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
来源:https://stackoverflow.com/questions/19875029/class-segmentation-fault-11


