Jump to content
  • Advertisement
Sign in to follow this  

Android Native Activity

This topic is 1126 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently looking into the Native Activity example that comes with the Android NDK and do I have some questions....
I'm looking to start out small, just printing a string when the activity lifecycle changes.
EG onCreate -> onState-> onPause- -> etc. But I kind of don't understand one thing
Maybe my C/C++ skills faded away pretty hard, but how are you supposed to "override" the onXXXX methods located in the android_native_app_glue.c?

For example in java I would extend the Activity class and just do
public void onPause()
      System.out.println("Activity was paused");
Maybe I'm thinking about this all wrong and I'm actually supposed to use the native_activity.h and create my own "glue" file.

Also does anyone have some solid tutorials on this topic? Ones that are little be more detailed then the samples that are include with the NDK.
Ones that take baby steps and explain what is actually going on Edited by noodleBowl

Share this post

Link to post
Share on other sites

Well,you are not supposed to do things that way.

Android entry function has a struct parameter.you can do everything with that , from creating asset manager to listening to activity events and even more.

don't forget to put the app_dummy() on the first line of your entry function.It is needed is the andoid application not android libraries.if you forget put this function you will get strange errors.There is a property in the android_app struct ,onAppCmd that , this is a function that you specify and will call everytime that something happen to your activity such as pause or resume or whatever.


void handle_cmd(struct android_app* app, int32_t cmd){


case case APP_CMD_PAUSE:

printf("Activity was paused");




Android event managing is very similiar with windows.you have an struct , you pass it to a function and you event manager function will call everytime an event occur.and there is appState in the app_struct that you can check for current event in you app loop.


sorry for bad english.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!