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?
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 ]