/*


Copyright 2014 Adrian Dawid

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


Created by Adrian Dawid

*/
package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;
import your.app.id.*;
import android.os.Bundle;
import com.google.android.gms.games.Games;
import android.content.Context;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import android.content.Intent;
import android.app.Activity;

public class MainActivity extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
        
        if (resultCode == ConnectionResult.SUCCESS){
            Intent intent = new Intent(this, AppActivity.class);
            AppActivity.gpgAvailable = true;
            startActivity(intent);
        }
        else{
            Intent intent = new Intent(this, NoGPGAppActivity.class);
            AppActivity.gpgAvailable = false;
            startActivity(intent);
        }
    }
}

@@ -608,16 +608,17 @@
 x.cpp;%0A%0A
+%0A
 import o
@@ -1020,16 +1020,59 @@
 tivity%7B%0A
+    public static boolean exiting = false;%0A
     @Ove
@@ -1178,16 +1178,47 @@
 State);%0A
+        if(!exiting)%0A        %7B%0A
         
@@ -1317,17 +1317,8 @@
 ));%0A
-        %0A
     
@@ -1647,24 +1647,24 @@
 le = false;%0A
-
             
@@ -1692,20 +1692,451 @@
 ;%0A        %7D%0A
+        %7D%0A        else%7B%0A            Intent intent = new Intent(Intent.ACTION_MAIN);%0A            intent.addCategory(Intent.CATEGORY_HOME);%0A            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);%0A            startActivity(intent);%0A        %7D%0A    %7D%0A    %0A    @Override%0A    public void onStop() %7B%0A        super.onStop();%0A        if(exiting)%0A        %7B%0A            android.os.Process.killProcess(android.os.Process.myPid());%0A        %7D%0A
     %7D%0A%7D%0A

Update MainActivity.java