Sign in to follow this  

Android Native Activity

This topic is 817 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){

switch(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

This topic is 817 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this