Advertisement
Selzier

Untitled

Oct 11th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1.    //----------------------------------------------------------------------
  2.    //-- START onCBshowInterstitial
  3.    //----------------------------------------------------------------------
  4.     void onCBshowInterstitial(unsigned char _iArgumentCount, const void *_pArguments, void *_pUserData){
  5.         JNIEnv *pJNIEnv = GetJNIEnv();
  6.         if (pJNIEnv){
  7.            
  8.             if ( _pArguments && ( _iArgumentCount > 0 ) ){
  9.                 const S3DX::AIVariable *pVariables = (const S3DX::AIVariable *)_pArguments ;
  10.                
  11.                 for ( uint8_t i = 0 ; i < _iArgumentCount ; i++ ){
  12.                     //We only want strings
  13.                    
  14.                     if(pVariables[i].GetType() == S3DX::AIVariable::eTypeString){
  15.                         //LOGI( "incrementAchievement returned string: %s", pVariables[i].GetStringValue() );
  16.                         //Find our main class so we can call the incrementAchievement function.  For me, my package name is:
  17.                         //com.hypercanestudios.acceleroketer
  18.                         //within that package I have a class called accelerocketer
  19.                         //so <package name>/<class name> and replace "." with "/"
  20.            
  21.                         // CHANGE ME!
  22.                         jclass pJNIActivityClass = pJNIEnv->FindClass ( "com/nurfacegames/fsaus16/fsaus16" );
  23.                        
  24.            
  25.                         if(pJNIActivityClass == NULL)
  26.                             LOGI("jclass was null!?!");
  27.                         else{
  28.                             //Now we have to find the function we're trying to call. We use the class defined above since the function
  29.                             //is a member of that class.  (Ljava/lang/String;) is the set of arguments that the function takes, a single String
  30.                             //V means that the function returns void
  31.                             //void incrementAchievement(String blah)
  32.                             //See table 3-2 http://docs.oracle.com/javase/1.3/docs/guide/jni/spec/types.doc.html#597
  33.                            
  34.                             jmethodID pJNIMethodID = pJNIEnv->GetStaticMethodID(pJNIActivityClass, "onCBshowInterstitial", "(Ljava/lang/String;)V" );
  35.                            
  36.                             if(pJNIMethodID == NULL)
  37.                                 LOGI("jmethodID was null!?!?");
  38.                             else{
  39.                                 //Create a new string
  40.                                 jstring arg;
  41.                                 arg = pJNIEnv->NewStringUTF(pVariables[i].GetStringValue());
  42.                                 //Call the method and pass the string parameter along
  43.                                 pJNIEnv->CallStaticVoidMethod(pJNIActivityClass, pJNIMethodID, arg);
  44.                                 //Free the string
  45.                                 pJNIEnv->DeleteLocalRef(arg);
  46.                             }
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.     }
  53.    
  54.    //----------------------------------------------------------------------
  55.    //-- END onCBshowInterstitial
  56.    //----------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement