Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pausing an activity

 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
To begin with, let me say that i am a beginner in android apps development. I am presently encountering a problem i find difficult to solve and i will be so thankful if somebody could help. Here it is:

I cannot pause my main activity that displays a logo for let say 5 seconds before the launch of the next activity that loads my website.

The layout file main.xml reads as follows:



My main activity code is as follows:



I added nested for loops in onResume method to delay the start of the next activity that launches my website but when i run the above code, i have a blank screen.
Any help?

Kind regards
 
arumugarani sundaram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the loop itself is not right to me.

I don't know android programming
but if you want to delay some activity you can use Thread.sleep for some fixed seconds

Hope this helps.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Busy looping is *never* a good idea, and even less so in the event thread of GUI frameworks (like Swing or Android).

One approach would be to show the interim layout, and set a timer to replace it after 5 seconds. Be aware that 5 seconds is a *very long time* in a user's perception - be prepared for users that are irate about the app getting in their way pointlessly.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just saw the previous response - don't ever use Thread.sleep in the event loop of a GUI framework.
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ulf,
I thank you so much for your guidance. It is always an honour to have you intervene in my topics. However, i do not know where in my code to set the timer and how to replace the interim layout. Can you lead me to the initial steps, please?
Kind regards
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WebViewActivity .java



webview.xml

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're showing a web page anyway, why not use a local page (meaning, one that is shipped with the app), and then replace it by the actual page after 5 seconds? You could even have HTML do the work for you (there's an HTTP header you can set that redirects automatically after N seconds). Be sure to include a link on the page for the user to click for cutting the 5 seconds short - few things are more annoying to a user than having to wait pointlessly.
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,
Thank you a lot. Modifying the header in my web page did the trick.
Good day!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic