com.badlogic.gdx.backends.android
Class AndroidApplication

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.view.ContextThemeWrapper
              extended by android.app.Activity
                  extended by com.badlogic.gdx.backends.android.AndroidApplication
All Implemented Interfaces:
android.content.ComponentCallbacks, android.content.ComponentCallbacks2, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.LayoutInflater.Factory2, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback, Application, AndroidApplicationBase

public class AndroidApplication
extends android.app.Activity
implements AndroidApplicationBase

An implementation of the Application interface for Android. Create an Activity that derives from this class. In the Activity.onCreate(Bundle) method call the initialize(ApplicationListener) method specifying the configuration for the GLSurfaceView.

Author:
mzechner

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.badlogic.gdx.Application
Application.ApplicationType
 
Field Summary
 android.os.Handler handler
           
 
Fields inherited from class android.app.Activity
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAPTIONING_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Fields inherited from interface com.badlogic.gdx.backends.android.AndroidApplicationBase
MINIMUM_SDK
 
Fields inherited from interface com.badlogic.gdx.Application
LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_NONE
 
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
 
Constructor Summary
AndroidApplication()
           
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
           
 void debug(String tag, String message)
           
 void debug(String tag, String message, Throwable exception)
           
 void error(String tag, String message)
           
 void error(String tag, String message, Throwable exception)
           
 void exit()
           
 ApplicationListener getApplicationListener()
           
 android.view.Window getApplicationWindow()
          Returns the Window associated with the application
 Audio getAudio()
           
 Clipboard getClipboard()
           
 android.content.Context getContext()
          The application or activity context
 Array<Runnable> getExecutedRunnables()
          The currently executed runnables
 Files getFiles()
           
 Graphics getGraphics()
           
 android.os.Handler getHandler()
          Returns the Handler object created by the application
 AndroidInput getInput()
          Returns the AndroidInput object associated with this AndroidApplicationBase
 long getJavaHeap()
           
 Array<LifecycleListener> getLifecycleListeners()
          Returns the LifecycleListener array associated with this AndroidApplicationBase
 int getLogLevel()
           
 long getNativeHeap()
           
 Net getNet()
           
 Preferences getPreferences(String name)
           
 Array<Runnable> getRunnables()
          A set of usable runnables
 Application.ApplicationType getType()
           
 int getVersion()
           
 void initialize(ApplicationListener listener)
          This method has to be called in the Activity.onCreate(Bundle) method.
 void initialize(ApplicationListener listener, AndroidApplicationConfiguration config)
          This method has to be called in the Activity.onCreate(Bundle) method.
 android.view.View initializeForView(ApplicationListener listener)
          This method has to be called in the Activity.onCreate(Bundle) method.
 android.view.View initializeForView(ApplicationListener listener, AndroidApplicationConfiguration config)
          This method has to be called in the Activity.onCreate(Bundle) method.
 void log(String tag, String message)
           
 void log(String tag, String message, Throwable exception)
           
 void onConfigurationChanged(android.content.res.Configuration config)
           
 void onWindowFocusChanged(boolean hasFocus)
           
 void postRunnable(Runnable runnable)
           
 void removeLifecycleListener(LifecycleListener listener)
           
 void setLogLevel(int logLevel)
           
 void useImmersiveMode(boolean use)
          Activates Android 4.4 KitKat's 'Immersive Mode' feature.
 
Methods inherited from class android.app.Activity
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onAttachedToWindow, onAttachFragment, onBackPressed, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onProvideAssistData, onRetainNonConfigurationInstance, onSearchRequested, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onWindowAttributesChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, reportFullyDrawn, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
 
Methods inherited from class android.view.ContextThemeWrapper
applyOverrideConfiguration, getResources, getTheme, setTheme
 
Methods inherited from class android.content.ContextWrapper
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.badlogic.gdx.backends.android.AndroidApplicationBase
getWindowManager, runOnUiThread, startActivity
 

Field Detail

handler

public android.os.Handler handler
Constructor Detail

AndroidApplication

public AndroidApplication()
Method Detail

initialize

public void initialize(ApplicationListener listener)
This method has to be called in the Activity.onCreate(Bundle) method. It sets up all the things necessary to get input, render via OpenGL and so on. Uses a default AndroidApplicationConfiguration.

Parameters:
listener - the ApplicationListener implementing the program logic

initialize

public void initialize(ApplicationListener listener,
                       AndroidApplicationConfiguration config)
This method has to be called in the Activity.onCreate(Bundle) method. It sets up all the things necessary to get input, render via OpenGL and so on. You can configure other aspects of the application with the rest of the fields in the AndroidApplicationConfiguration instance.

Parameters:
listener - the ApplicationListener implementing the program logic
config - the AndroidApplicationConfiguration, defining various settings of the application (use accelerometer, etc.).

initializeForView

public android.view.View initializeForView(ApplicationListener listener)
This method has to be called in the Activity.onCreate(Bundle) method. It sets up all the things necessary to get input, render via OpenGL and so on. Uses a default AndroidApplicationConfiguration.

Note: you have to add the returned view to your layout!

Parameters:
listener - the ApplicationListener implementing the program logic
Returns:
the GLSurfaceView of the application

initializeForView

public android.view.View initializeForView(ApplicationListener listener,
                                           AndroidApplicationConfiguration config)
This method has to be called in the Activity.onCreate(Bundle) method. It sets up all the things necessary to get input, render via OpenGL and so on. You can configure other aspects of the application with the rest of the fields in the AndroidApplicationConfiguration instance.

Note: you have to add the returned view to your layout!

Parameters:
listener - the ApplicationListener implementing the program logic
config - the AndroidApplicationConfiguration, defining various settings of the application (use accelerometer, etc.).
Returns:
the GLSurfaceView of the application

onWindowFocusChanged

public void onWindowFocusChanged(boolean hasFocus)
Specified by:
onWindowFocusChanged in interface android.view.Window.Callback
Overrides:
onWindowFocusChanged in class android.app.Activity

useImmersiveMode

public void useImmersiveMode(boolean use)
Description copied from interface: AndroidApplicationBase
Activates Android 4.4 KitKat's 'Immersive Mode' feature.

Specified by:
useImmersiveMode in interface AndroidApplicationBase
Parameters:
use - Whether or not to use immersive mode

getApplicationListener

public ApplicationListener getApplicationListener()
Specified by:
getApplicationListener in interface Application

getAudio

public Audio getAudio()
Specified by:
getAudio in interface Application

getFiles

public Files getFiles()
Specified by:
getFiles in interface Application

getGraphics

public Graphics getGraphics()
Specified by:
getGraphics in interface Application

getInput

public AndroidInput getInput()
Description copied from interface: AndroidApplicationBase
Returns the AndroidInput object associated with this AndroidApplicationBase

Specified by:
getInput in interface Application
Specified by:
getInput in interface AndroidApplicationBase
Returns:
the AndroidInput object

getNet

public Net getNet()
Specified by:
getNet in interface Application

getType

public Application.ApplicationType getType()
Specified by:
getType in interface Application

getVersion

public int getVersion()
Specified by:
getVersion in interface Application

getJavaHeap

public long getJavaHeap()
Specified by:
getJavaHeap in interface Application

getNativeHeap

public long getNativeHeap()
Specified by:
getNativeHeap in interface Application

getPreferences

public Preferences getPreferences(String name)
Specified by:
getPreferences in interface Application

getClipboard

public Clipboard getClipboard()
Specified by:
getClipboard in interface Application

postRunnable

public void postRunnable(Runnable runnable)
Specified by:
postRunnable in interface Application

onConfigurationChanged

public void onConfigurationChanged(android.content.res.Configuration config)
Specified by:
onConfigurationChanged in interface android.content.ComponentCallbacks
Overrides:
onConfigurationChanged in class android.app.Activity

exit

public void exit()
Specified by:
exit in interface Application

debug

public void debug(String tag,
                  String message)
Specified by:
debug in interface Application

debug

public void debug(String tag,
                  String message,
                  Throwable exception)
Specified by:
debug in interface Application

log

public void log(String tag,
                String message)
Specified by:
log in interface Application

log

public void log(String tag,
                String message,
                Throwable exception)
Specified by:
log in interface Application

error

public void error(String tag,
                  String message)
Specified by:
error in interface Application

error

public void error(String tag,
                  String message,
                  Throwable exception)
Specified by:
error in interface Application

setLogLevel

public void setLogLevel(int logLevel)
Specified by:
setLogLevel in interface Application

getLogLevel

public int getLogLevel()
Specified by:
getLogLevel in interface Application

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Specified by:
addLifecycleListener in interface Application

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Specified by:
removeLifecycleListener in interface Application

getContext

public android.content.Context getContext()
Description copied from interface: AndroidApplicationBase
The application or activity context

Specified by:
getContext in interface AndroidApplicationBase
Returns:
the Context

getRunnables

public Array<Runnable> getRunnables()
Description copied from interface: AndroidApplicationBase
A set of usable runnables

Specified by:
getRunnables in interface AndroidApplicationBase
Returns:
the Runnable array

getExecutedRunnables

public Array<Runnable> getExecutedRunnables()
Description copied from interface: AndroidApplicationBase
The currently executed runnables

Specified by:
getExecutedRunnables in interface AndroidApplicationBase
Returns:
the Runnable array

getLifecycleListeners

public Array<LifecycleListener> getLifecycleListeners()
Description copied from interface: AndroidApplicationBase
Returns the LifecycleListener array associated with this AndroidApplicationBase

Specified by:
getLifecycleListeners in interface AndroidApplicationBase
Returns:
the array of LifecycleListener's

getApplicationWindow

public android.view.Window getApplicationWindow()
Description copied from interface: AndroidApplicationBase
Returns the Window associated with the application

Specified by:
getApplicationWindow in interface AndroidApplicationBase
Returns:
The Window associated with the application

getHandler

public android.os.Handler getHandler()
Description copied from interface: AndroidApplicationBase
Returns the Handler object created by the application

Specified by:
getHandler in interface AndroidApplicationBase
Returns:
The Handler object created by the application


Copyright © 2014. All Rights Reserved.