Merge pull request #405 from minggo/iss618

invoke java code(System.exit()) to finish programe
This commit is contained in:
minggo 2011-07-19 02:20:36 -07:00
commit 0c495628ea
6 changed files with 36 additions and 7 deletions

View File

@ -181,6 +181,10 @@ public class Cocos2dxActivity extends Activity{
public static String getCocos2dxPackageName(){
return packageName;
}
public static void terminateProcess(){
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
protected void onResume() {

View File

@ -181,6 +181,10 @@ public class Cocos2dxActivity extends Activity{
public static String getCocos2dxPackageName(){
return packageName;
}
public static void terminateProcess(){
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
protected void onResume() {

View File

@ -98,7 +98,7 @@ bool CCEGLView::isOpenGLReady()
void CCEGLView::release()
{
exit(0);
terminateProcessJNI();
}
void CCEGLView::setTouchDelegate(EGLTouchDelegate * pDelegate)

View File

@ -456,4 +456,20 @@ extern "C"
return ret;
}
//////////////////////////////////////////////////////////////////////////
// terminate the process
//////////////////////////////////////////////////////////////////////////
void terminateProcessJNI()
{
TMethodJNI t;
if (getMethodID(t
, "org/cocos2dx/lib/Cocos2dxActivity"
, "terminateProcess"
, "()V"))
{
t.env->CallStaticObjectMethod(t.classID, t.methodID);
}
}
}

View File

@ -30,12 +30,13 @@ extern "C"
{
extern JavaVM *gJavaVM;
void enableAccelerometerJNI();
void disableAccelerometerJNI();
void showMessageBoxJNI(const char * pszMsg, const char * pszTitle);
void setKeyboardStateJNI(int bOpen);
char* getCurrentLanguageJNI();
char* getPackageNameJNI();
extern void enableAccelerometerJNI();
extern void disableAccelerometerJNI();
extern void showMessageBoxJNI(const char * pszMsg, const char * pszTitle);
extern void setKeyboardStateJNI(int bOpen);
extern char* getCurrentLanguageJNI();
extern char* getPackageNameJNI();
extern void terminateProcessJNI();
}
#endif // __ANDROID_COCOS2D_JNI_H__

View File

@ -181,6 +181,10 @@ public class Cocos2dxActivity extends Activity{
public static String getCocos2dxPackageName(){
return packageName;
}
public static void terminateProcess(){
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
protected void onResume() {