O'Reilly logo

Android NDK Beginner's Guide by Sylvain Ratabouil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – displaying raw graphics and implementing a timer

First, let's implement a timer in a dedicated module:

Note

Throughout this book, we will implement several modules named with the postfix Service. These services are purely design concepts and are not related to Android services.

  1. In the jni directory, create TimeService.hpp which includes time.h Posix header.

    It contains methods reset() and update() to manage timer state and two interrogation methods to read current time (method now()) and the time elapsed in seconds between the last two updates (method elapsed()):

    #ifndef _PACKT_TIMESERVICE_HPP_ #define _PACKT_TIMESERVICE_HPP_ #include "Types.hpp" #include <time.h> namespace packt { class TimeService { public: TimeService(); void reset(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required