Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9238547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:47:18+00:00 2026-06-18T07:47:18+00:00

I am trying to implement Timer() in the main activity. But, somehow it is

  • 0

I am trying to implement Timer() in the main activity. But, somehow it is not working as I expect. I will show key code section to you.
ERROR :
icon is not changed

public class X extends Activity {
       private Timer timer = new Timer () ;
       setContentView(R.layout.main);
       public void onCreate(Bundle a) {
              //..
              timer.scheduleAtFixedRate( new Device(),  1000, 1000  );

       }

}

public class Device extends TimerTask {
       Image e;
       View w;
       public void run() {
           e = ( ImageView ) w.findViewById(R.id.imageView1);
           if ( isVolited ( ))
                   e.setBackground(w.getResources().getDrawable(R.drawable.icon1));
               else
                   e.setBackground(w.getResources().getDrawable(R.drawable.icon2));

LOG :

 01-29 14:25:51.175: E/TabletStatusBar(2172): closing mini mode apps panel
 01-29 14:25:51.255: E/TabletStatusBar(2172): closing mini mode apps panel
 01-29 14:25:56.510: E/lights(2051): write_int failed to open /sys/class/sec/sec_touchkey/brightness
 01-29 14:25:59.105: E/lights(2051): write_int failed to open /sys/class/sec/sec_touchkey/brightness
 01-29 14:26:00.060: E/TODmobile(3509): onReceive action=android.intent.action.TIME_TICK
 01-29 14:26:00.060: E/TODmobile(3509): hour : 14    minute : 26
 01-29 14:26:00.060: E/DigitalClockWidget(3509): updateWidgets
 01-29 14:26:00.065: E/TODmobile(3509): hour : 14    minute : 26
 01-29 14:26:10.725: E/Watchdog(2051): !@Sync 504
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:47:19+00:00Added an answer on June 18, 2026 at 7:47 am

    Try this code, it is working

    Timer time = new Timer();
    TimerTask doThis;
    
    int delay = 1000; // delay for 5 sec.
    int period = 1000; // repeat every sec.
    doThis = new TimerTask() {
        public void run() {
    
            e = (ImageView) findViewById(R.id.imageView1);
    
            runOnUiThread(new Runnable() {
                public void run() {
    
    
                    e.setImageResource(R.drawable.ic_launcher);
    
                }
    
            });
    
        }
    };
    time.scheduleAtFixedRate(doThis, delay, period);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a generic timer function in OCaml which will take
I'm trying to implement a critical section in CUDA using atomic instructions, but I
I am trying to implement Joda-Time to count down to Christmas, but so far
Trying to implement 3-layer (not: tier, I just want to separate my project logically,
Hai am trying to get the gps location using BroadCast Receiver.its working fine,But i
Am I doing this right? I'm trying to implement a simple countdown timer just
I'm trying to implement a basic qtimer in a qgraphicsview but can't seem to
I'm trying to implement returning from an Activity without needing to refresh the screen.
I'm trying to implement an activity with an EditText that replaces some keywords with
I am trying to implement a filmstrip-like UIScrollView that will be populated with thumbnails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.