Example #1
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void
android_main (struct android_app* application)
{
  TestData data;

  /* Make sure glue isn't stripped */
  app_dummy ();

  g_android_init ();

  memset (&data, 0, sizeof (TestData));
  application->userData = &data;
  application->onAppCmd = test_handle_cmd;
  data.app = application;

  while (1)
    {
      int events;
      struct android_poll_source* source;

      while ((ALooper_pollAll (0, NULL, &events, (void**)&source)) >= 0)
        {

          /* Process this event */
          if (source != NULL)
            source->process (application, source);

          /* Check if we are exiting */
          if  (application->destroyRequested != 0)
            {
              test_fini (&data);
              return;
            }
      }

      test_draw_frame_and_swap (&data);
    }
}
Example #2
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things
 */
void
android_main (struct android_app* application)
{
  TestData data;
  GMainLoop *main_loop;

  /* Make sure glue isn't stripped */
  app_dummy ();

  g_android_init ();

  memset (&data, 0, sizeof (TestData));
  application->userData = &data;
  application->onAppCmd = test_handle_cmd;
  application->onInputEvent = test_handle_input;
  data.app = application;

  main_loop = g_main_loop_new (NULL, FALSE);

  g_timeout_add_seconds (5, print_message, "Hello, World!");

  g_main_loop_run (main_loop);
}