Delay before start activity

ianrich

Member
Licensed User
Longtime User
If anyone can shed some light on the following it would be much appreciated...
:sign0085:
I am using one Main activity for an app. This Main activity uses StartActivity("Help") to start a second activity to display help about the app. It does work as expected, however, once the Help activity has been closed (it uses Activity.Finish) then the Main activity is unable to re-start the Help activity again until after a wait of around 6-8 seconds. I'd like the user to be able to call up the help activity without delay if this is possible. Thanks in advance.
 

ianrich

Member
Licensed User
Longtime User
Thanks for the correction and super fast response. I updated the code as you suggested but, unfortunately, it hasn't changed the behaviour.
 
Upvote 0

IanMc

Well-Known Member
Licensed User
Longtime User
You could try simply not closing it.

From your Help Activity when you want to exit just

StartActivity(Main)

See if that makes a difference.
 
Upvote 0

ianrich

Member
Licensed User
Longtime User
This is an internal delay managed by the OS. You can use CallSubDelayed instead of StartActivity. CallSubDelayed has a built-in retry mechanism.

Thanks for this. I tried CallSubDelayed and the log shows the call ok, however, the behaviour is still unchanged from StartActivity.

I did another test using a simple project and there was no delay when re-starting a second activity in that. I need to experiment further but it's now 4am here!
 
Upvote 0

ianrich

Member
Licensed User
Longtime User
You could try simply not closing it.

From your Help Activity when you want to exit just

StartActivity(Main)

See if that makes a difference.

Thanks for your idea, and it actually worked - except it created an endless loop between the two activities and I was unable to close the app! Maybe some variation of this may be useful...
 
Upvote 0

IanMc

Well-Known Member
Licensed User
Longtime User
well, you normally wouldn't have main calling help in a loop, you'd normally have to press a button in main to get to help.

Exiting help you can just call main again.

Sub buttonHelp_Click
StartActivity(Help)
End Sub

something like that.

Now go to bed Ian! Its 4am there!
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Look at the manifest Activity attribute android:noHistory.

Whether or not the activity should be removed from the activity stack and finished (its finish() method called) when the user navigates away from it and it's no longer visible on screen — "true" if it should be finished, and "false" if not. The default value is "false".

A value of "true" means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it.

This attribute was introduced in API Level 3.

Sounds like it should do the job - you just need to work out the syntax to use in the manifest editor.

Martin.
 
Upvote 0

ianrich

Member
Licensed User
Longtime User
Look at the manifest Activity attribute android:noHistory.

Sounds like it should do the job - you just need to work out the syntax to use in the manifest editor.

Martin.

Thanks, I thought your tip might be the answer with this in the manifest...
SetManifestAttribute("android:noHistory", "true")

But, the delay issue is still there.
 
Upvote 0

ianrich

Member
Licensed User
Longtime User
I've been testing on ICS 4.0.4 but tried the app today on JB and there's no delay evident so that indicates the code is probably ok.

:sign0188:
Excellent forum, thanks for the replies and sharing your expertise.
 
Upvote 0
Top