Question

I am attempting to initialize some variables in java and then send them to my native code. I need to delay the nativeactivity call so that the java variables get time to get initialized and then they can be passed to the native activity.

My main problem is that the native activity keeps being called as soon as my activity starts as i have extended my class from NativeActivity(which is compulsory). As soon as onCreate() is called after super my native activity automatically is started and my java variables are not initialized yet.

No correct solution

OTHER TIPS

You can use handler into your class.

Below is my code which is working to perform delay operations:

private void cal(){     
 final Handler handler2 = new Handler();
       Runnable runnable = new Runnable() {
      int i=0;
      public void run()
      {                                     
       if(i==0)
        {      
          // Enter your code here which you want run after some deley.                   

    i++;
        }
        handler2.postDelayed(this, 2000);
      }
     };   
   handler2.postDelayed(runnable, 2000); 
    }    

Call this function into your main class.

Hope it will work for you also.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top