Is there a way to measure the screen refresh time of an android device?
I want to know the time spent drawing a text on the screen after calling the setText method.
You can override the onDraw
method of a TextView
to find out when it's actually redrawn.
public class MyTextView extends android.widget.TextView {
private long mUpdateTime;
public MyTextView(Context context) {
super(context);
}
public void mySetText(CharSequence text) {
mUpdateTime = System.currentTimeMillis();
super.setText(text);
}
@Override
public void onDraw(Canvas c) {
super.onDraw(c);
long refreshTime = System.currentTimeMillis() - mUpdateTime;
//Do something with refreshTime
}
}