Application / Activity Life Cycle Problem

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Application / Activity Life Cycle Problem

Postby VIDEN » Wed Jul 22, 2009 4:09 pm

Hey,

I am having real problems with the Android 1.5 Activity Lifecycles, and I don't know how you guys manage these.

Well I have an Application with two activities: My MainActicity and a SettingsActivity.

I got rid of all the memory leaks when changing the orientation. The Program gets distroyed correcktly in my onDistroy() method.

In my onPause() method I stop my active networkconnections (I use soap websevces to get data) but do not distroy the environment...

Here is my Problem:
If I press the Home-Key while my app is started, onPause() and onStop() are called, the app gets paused correctly. --> I see the Home Screen.

If I hold the Home-Key down now and select my app in the popup menue onRestart, onStart and onResume are called. My App gets displayed again and everything is fine.

BUT if I do not access my App this way, but instead press my app icon on the Home screen the following happenes:
EVENTHOUGH my App is already started and still running the
onCreate() Method is called and my Acivity gets fully reloaded, eventhough it is loaded already.
So now my activity is running two times and if I do that a couple of times of course I'll run into memory problems.

now how do I solve this Problem?
Obviously I have to stop my Activity from loading more than once.... This would be easy if I could determine if an instance is running in the OnCreate() Method, but I can't find a way of doing this.

Any ideas?
How do you solve this problem?

Thanx David
VIDEN
Developer
Developer
 
Posts: 32
Joined: Tue May 12, 2009 9:39 am
Location: Germany

Top

Postby VIDEN » Fri Jul 24, 2009 8:46 am

Anyone? Please?

Greets
VIDEN
Developer
Developer
 
Posts: 32
Joined: Tue May 12, 2009 9:39 am
Location: Germany

Postby virtual » Fri Jul 24, 2009 2:08 pm

I think Intent's Flags will work for you. Just use those Flags while starting your Activities.

for e.g Intent.FLAG_ACTIVITY_NO_HISTORY etc.

Just go through these flags and see if it works.
Regards,
Virtual
virtual
Developer
Developer
 
Posts: 26
Joined: Tue Mar 24, 2009 11:20 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 12 guests