Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display Activity for 5 seconds.

 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to display one activity which has one ImageView displaying an image. I want to display that just for 5 seconds the move on to another activity.

I tried using thread mechanism. But did not work.
Following is my code.



Please help.
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand how you are expecting that code to work. You are starting a new thread which is sleeping for 3 seconds and then dying. That won't stop the main thread to stop. What might work for you is you start the intent inside the thread that you started...
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

I triead that too.It gives The constructor Intent(new Runnable(){}, Class<Choices>) is undefined error.
Can you tell me what this error is. And Is there any inner mechanism to display activity for specific time period.
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hardik Trivedi wrote:Hi Ankit,

I triead that too.It gives The constructor Intent(new Runnable(){}, Class<Choices>) is undefined error.
Can you tell me what this error is. And Is there any inner mechanism to display activity for specific time period.


You need to pass a Context as first argument to the Intent constructor; instead you passed a Runnable.
For e.g.: you can move the following two lines inside run after the sleep call:
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. It works fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic