Don't use a Java Timer / TimerTask to update the UI. If you are lucky, it won't do anything, or else it can crash.

This explains why and what to use instead:

http://developer.android.com/resources/articles/timed-ui-updates.html

-- Kostya

18.02.2011 15:17, Abhilash baddam ?????:
Hi,

I am trying to rotate an image for every 3 secs, but it's not working. I did like this
but not working..what may be the reason..?

public class TimerEx extends Activity {
Timer timer;
     ImageView image;
Bitmap bMap = null;
Bitmap bitmap;
Matrix mat = new Matrix();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
System.out.println("Inside create");
image = (ImageView) findViewById(R.id.test_image);
bMap = BitmapFactory.decodeResource(getResources(), R.drawable.image);
     image.setImageBitmap(bMap);
     timer=new Timer();
     timer.schedule(new UpdateImage(),100,3000);
}
class UpdateImage extends TimerTask
{
@Override
public void run() {
mat.postRotate(45);
bitmap=Bitmap.createBitmap(bMap,0,0, bMap.getWidth(), bMap.getHeight(), mat, false);
image.setImageBitmap(bitmap);
}
}
}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to