1

I tought this was easier but I just can't find a solution: I have a simple View based Layout in Android with the layout.xml and all that and now I am currently looking for a function that is called each frame. I've tried overriding the draw() function in a custom layout (and calling this.setWillNotDraw(false); in the constructor) but this doesn't seem to be it.

Can anyone tell me which function is called each frame in Android?

  • Android does not strictly work on a frame-based system. You might consider explaining what you are trying to accomplish on every frame, so people here can help you solve your actual problem. – CommonsWare May 25 '15 at 12:53
  • You probably want to override `onDraw()` and not `draw()` for a start. Then you could call `invalidate()` at the end of it to get some kind of a frame based approach. – ci_ May 25 '15 at 12:57
  • But won't calling `invalidate()` force another draw? I want to access the Android pendant of some kind of render function. I want to measure performance in terms of FPS, and that specifically when certain animations are active. Is there any other way of doing that? Actually, I'm comparing an OpenGL based application (using libgdx) with an application of View based elements. In the OpenGL variant, I can make use of the `render()` function, and now I want to put the same code I use for performance measurement into the function that pure Android calls each frame. – user3465898 May 25 '15 at 17:16
  • Calling `invalidate()` will force another draw, yes, exactly, that's the point, you get some sort of cheap frame based system that way. But maybe that's not what you want. Also comparing an OpenGL based application with a view hierarchy based one is probably not very useful. You can always use OpenGL ES in your android application. – ci_ May 25 '15 at 20:32
  • Isn't there a way to somehow get the current FPS without influencing the rendering by calling `invalidate()`? Btw, this comparison in performance between these diverse mechanics is exactly what I'm trying to achieve. – user3465898 May 25 '15 at 21:23
  • I don't think it's feasible to make that comparison you're trying to make, also read here http://stackoverflow.com/questions/10983486/fps-testing-in-android-application – ci_ May 27 '15 at 09:05

0 Answers0