Please follow the steps below:
Firemonkey Moblie Application
TGeustureManager
component to the FormAdd 2 TButton
components to the Form
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;
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:
Location
Demo project that comes with Delphi xe5.TButton
component to Location
Label as shown in the image below:
OnClick
Event.Is this a bug should I report? or am I doing something wrong?
A common run-time error for C programs by beginners is a "segmentation violation" or "segmentation fault." When you run your program and the system reports a "segmentation violation," it means your program has attempted to access an area of memory that it is not allowed to access.
A segmentation fault (aka segfault) is a common condition that causes programs to crash; they are often associated with a file named core . Segfaults are caused by a program trying to read or write an illegal memory location.
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 ]
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With