Android Question Always open last activity

ducphu

Active Member
Licensed User
Longtime User
Hi all,

My app has a few activities. Let say I open a child activity then press Home button to close the app, when I re-open the app, I always see my last opened activity, even if I purposely kill the app to get rid of it from the memory. What should be the problem here?
 

ducphu

Active Member
Licensed User
Longtime User
Which activity? I didn't close any activity. If my last opened activity is a child activity, every time I open the app I will see that child activity. Even I kill the process, it doesn't open my main activity as it should be, but it still load that child activity.
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
Hi klaus,

It's difficult. My app is a large project and if I don't know where the problem is. If I make a simple project, I'm unable to generate the problem.
Anyway, I notice that, if I force stop the app, it will load back my main activity. Does it make any clue?
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
Below is the log:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (update) Create **
** Service (update) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (activity2) Create, isFirst = true **
** Activity (activity2) Resume **
** Activity (activity2) Pause, UserClosed = false ** 'Close App by pressing Home button

' Manually kill the process, then open app again

** Activity (activity2) Create, isFirst = true **
** Activity (activity2) Resume **
** Activity (activity2) Pause, UserClosed = false **
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
Hi klaus,

I just use the Two Activities example (https://www.b4x.com/android/forum/threads/two-activities-example.6611) to test and it happens exactly the same as my app. the log is:

** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (activity2) Create, isFirst = true **
** Activity (activity2) Resume **
** Activity (activity2) Pause, UserClosed = false **
' Manually kill the process, then open app again
** Activity (activity2) Create, isFirst = true **
** Activity (activity2) Resume **
** Activity (activity2) Pause, UserClosed = false **

I'm confused. So, is this normal??? I tested some apps on the market. If I kill those apps, they will open with the main activity.
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
@klaus I dont use Activity.Finish and yes I know if the app is not killed, it will be opened with last activity. But,my problem is, even I purposely kill the app, it is still opened with the last activity, which I dont want.
@Peter Simpson I dont want to make it complicate. Basically, what I want is, if my app is NOT killed, it is opened with last activity. If my app is killed, it should be opened with main activity. My problem here is, even my app is killed, it is still opened with last activity.

Hope I explained my problem clearly.
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
@klaus Weird, to me that example doesn't work as expected.
I kill the app using an app from the market, i.e Watchdog
If that example works for you then maybe Watchdog doesn't really kill the app :eek:
Any suggestion how to or which app can be used to "really" kill the app.

P/S I just tested using Watchdog to kill some commercial apps like LINE Tools, Unit Converter.
What I observed is, for LINE Tools, after being killed by Watchdog, it open and show the main activity.
For Unit Converter, after being killed by Watchdog, it open and show the last activity.
uhmm so I think there should be some tricks behind to determine which activity will be showed....:confused:
 
Last edited:
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
@thedesolatesoul thx you... if I use recents menu to kill, the app will load back main activity. Interesting, so those process killers don't really kill the process... I'm wondering what those apps do...
@parijs oh yeah maybe...that app has many functions and I didn't think that they put them all in 1 activity....
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
@thedesolatesoul thx you... if I use recents menu to kill, the app will load back main activity. Interesting, so those process killers don't really kill the process... I'm wondering what those apps do...
After killing them, were you loading them from the recents menu or from the home screen?
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
Apps / Running doesn't seem to be reliable. I test with "Two Activities" example. When the app is not in the running list, both "running services" and "cached processes", the app seems still alive. It still loads the last opened activity.
 
Upvote 0
Top