1

This has been asked before but not fully answered and I don't have the "reputation" to comment there. I want to exit an app for two reasons. 1. on startup if problems with the data files and 2. from a back-button press.

Another questioner got answers of using:

SharedActivity.Finish;

or

MainActivity.Finish;

Both appear to close the window but neither exit the application as in debug mode the program does not end in Delphi and the application is still running on the device itself.

Any more ideas? The hardware is a Nexus 4.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
Dave Lane
  • 41
  • 1
  • 3
  • possible duplicate of [How to close android app in Delphi-XE5 Firemonkey application?](http://stackoverflow.com/questions/19234502/how-to-close-android-app-in-delphi-xe5-firemonkey-application) – Qantas 94 Heavy Jun 14 '14 at 09:58
  • @Qantas94Heavy This is an extension of that question not the same. – Toby Allen Jun 15 '14 at 20:28

2 Answers2

0

Both appear to close the window but neither exit the application as in debug mode the program does not end in Delphi and the application is still running on the device itself.

This is perfectly normal for Android applications. The process will be terminated, eventually, by the operating system, as system RAM is needed for other processes .Please leave this alone and solve whatever problems you are encountering in some other fashion.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • It seems a bit simplistic to just ignore it, at least for Delphi android apps. The apps seem to eventually go away when that state, but if you try to run it again, it hangs... that happens if its run again from the icon, or selected from the list of running apps button. – Dave Lane Dec 02 '13 at 14:48
  • @DaveLane: "but if you try to run it again, it hangs" -- I cannot say whether this is a bug in Delphi or a bug in your app, but it is a bug. I would focus on fixing the bug. – CommonsWare Dec 02 '13 at 15:11
  • Well, lets leave it at that until someone with Delphi-Android experience comments. – Dave Lane Dec 02 '13 at 19:06
  • Did you manage to solve your issue? I'm facing a situatuon, where the app "closes" on back button pressed, but right afterwards I get a message "Unfortunatelly, MyApp has stopped." The fact is that I want it to stop, but not displaying this message. – That Marc Jan 24 '14 at 06:25
0

This is works for me:

FreeAndNil(Application);

I tried these before, but they all don't work for me:

  • SharedActivity.Finish
  • MainActivity.Finish
  • Application.MainForm.DisposeOf
Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
xJernej
  • 194
  • 2
  • 3
  • 14
  • If the question is a duplicate, please flag one of the questions as a duplicate instead of posting exactly the same answer on two questions. – Qantas 94 Heavy Jun 14 '14 at 09:59