Back to project page diploma-assignment.
The source code is released under:
MIT License
If you think the Android project diploma-assignment listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.me.mygdxgame; //from ww w . j a v a 2 s. c o m import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.KeyEvent; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import com.me.main.MyGame; public class MainActivity extends AndroidApplication { private static final int DIALOG_REALLY_EXIT_ID = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); cfg.useGL20 = false; initialize(new MyGame(), cfg); } @Override protected Dialog onCreateDialog(int id) { final Dialog dialog; switch(id) { case DIALOG_REALLY_EXIT_ID: dialog = new AlertDialog.Builder(this).setMessage( "Are you sure you want to exit?") .setCancelable(false) .setPositiveButton("Yes",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MainActivity.this.finish(); } }) .setNegativeButton("No",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).create(); break; default: dialog = null; } return dialog; } @SuppressWarnings("deprecation") @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) showDialog(DIALOG_REALLY_EXIT_ID); return true; } }