Shutting down an Android App

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Shutting down an Android App

Post by andyh1234 » Mon Dec 05, 2011 9:26 pm

Whats the best way to let the user shut down an android app?

Ive tried a simple 'quit', but all that happens is the app closes, then when its relaunched it just shows a black screen. On further investigation, although the app appears to close when the quit is issued, it actually keeps running.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Shutting down an Android App

Post by mwieder » Mon Dec 05, 2011 9:39 pm

Whats the best way to let the user shut down an android app?
Don't.

Not necessary, not recommended. Android apps run during the current session. Trying to close them can do weird things to system garbage collection.

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Shutting down an Android App

Post by andyh1234 » Mon Dec 05, 2011 11:46 pm

Hmm, ok.

The issue I had was I have a reset app feature in the iPhone version. Its lazy, but it just deletes all the data files and then closes the app. When the user restarts it starts up like new.

It looks like I can't do the same on Android, so Ill have to wipe the files and vars etc and just call the startup routine again instead.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Shutting down an Android App

Post by mwieder » Tue Dec 06, 2011 12:04 am


BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Shutting down an Android App

Post by BarrySumpter » Wed Dec 07, 2011 10:38 pm

Thats an interesting read.
We'd need a translation into LiveCode do's n don'ts.
I'd be intersted in reading more of his posts.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Shutting down an Android App

Post by andyh1234 » Wed Dec 07, 2011 11:22 pm

And to be honest, its absolutely right.

Ive removed the quit button from the first setup screen and it already looks a lot more like an Android app!

Now I just need to work out the code to get the app to restart cleanly with all settings removed and all stacks put back to their designed state, I guess if unload all the substacks, then run the initial device detection script which will detect Android and reload the Android substack that should do the trick!

Andy

Nick Johnson
Posts: 16
Joined: Fri Jun 29, 2012 8:05 am

Re: Shutting down an Android App

Post by Nick Johnson » Fri Aug 03, 2012 6:42 am

How about this :-
Shut them down manually by navigating to Settings > Applications > Running Services. To close open apps, tap them. The hyper-efficient can also download the free version of Advanced Task Killer from the Android Market.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Shutting down an Android App

Post by Simon » Sun Aug 19, 2012 3:23 pm

OK, now I have a real case for the Home button shutting down an app.
I made a simple "Pong" game (never done collision detection before) complete with original sound effects. Guess what happens if a user is playing the game and hits the Home button because their boss walks in the room. Yeah, they lose their jobs as the game happily plays away in their pocket. :cry:
Most users do not know the difference between hitting the Back button and hitting the Home button.

So, is their any update to trapping the Home button? Tried:
suspend
suspendStack
closeStack
shutDown
and swearing, none seem to help.

Thanks,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Shutting down an Android App

Post by Klaus » Sun Aug 19, 2012 5:16 pm

Hi Simon,

maybe "closeStackRequest"?


Best

Klaus

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Shutting down an Android App

Post by Simon » Mon Aug 20, 2012 11:58 am

Hi Klaus,
Thanks but still no luck.
I can't be the first LC developer who uses sound fx in a twitch game.
ACK! Just thought of a workaround:
on touchStart
set playLoudness to 50
end touchstart
on touchEnd
set playLoudness to 0
end touchEnd

Oh, that is very ugly. Anybody else have an idea?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply