Added in API level 9

NativeActivity


open class NativeActivity : Activity, SurfaceHolder.Callback2, InputQueue.Callback, ViewTreeObserver.OnGlobalLayoutListener
kotlin.Any
   ↳ android.content.Context
   ↳ android.content.ContextWrapper
   ↳ android.view.ContextThemeWrapper
   ↳ android.app.Activity
   ↳ android.app.NativeActivity

Convenience for implementing an activity that will be implemented purely in native code. That is, a game (or game-like thing). There is no need to derive from this class; you can simply declare it in your manifest, and use the NDK APIs from there.

A sample native activity is available in the NDK samples.

Summary

Constants
static String

Optional meta-that can be in the manifest for this component, specifying the name of the main entry point for this native activity in the META_DATA_LIB_NAME native code.

static String

Optional meta-that can be in the manifest for this component, specifying the name of the native shared library to load.

Inherited constants
Public constructors

Public methods
open Unit

open Unit

open Unit

open Unit

open Unit

open Unit

open Unit
surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int)

open Unit

open Unit

open Unit

Protected methods
open Unit
onCreate(savedInstanceState: Bundle?)

open Unit

open Unit

open Unit

open Unit

open Unit

open Unit

Inherited functions
Inherited properties

Constants

META_DATA_FUNC_NAME

Added in API level 9
static val META_DATA_FUNC_NAME: String

Optional meta-that can be in the manifest for this component, specifying the name of the main entry point for this native activity in the META_DATA_LIB_NAME native code. If not specified, "ANativeActivity_onCreate" is used.

Value: "android.app.func_name"

META_DATA_LIB_NAME

Added in API level 9
static val META_DATA_LIB_NAME: String

Optional meta-that can be in the manifest for this component, specifying the name of the native shared library to load. If not specified, "main" is used.

Value: "android.app.lib_name"

Public constructors

NativeActivity

NativeActivity()

Public methods

onConfigurationChanged

Added in API level 9
open fun onConfigurationChanged(newConfig: Configuration): Unit
Parameters
newConfig Configuration: The new device configuration. This value cannot be null.

onGlobalLayout

Added in API level 9
open fun onGlobalLayout(): Unit

onInputQueueCreated

Added in API level 9
open fun onInputQueueCreated(queue: InputQueue!): Unit

onInputQueueDestroyed

Added in API level 9
open fun onInputQueueDestroyed(queue: InputQueue!): Unit

onLowMemory

Added in API level 9
open fun onLowMemory(): Unit

onWindowFocusChanged

Added in API level 9
open fun onWindowFocusChanged(hasFocus: Boolean): Unit
Parameters
hasFocus Boolean: Whether the window of this activity has focus.

surfaceChanged

Added in API level 9
open fun surfaceChanged(
    holder: SurfaceHolder,
    format: Int,
    width: Int,
    height: Int
): Unit
Parameters
holder SurfaceHolder: The SurfaceHolder whose surface has changed. This value cannot be null.
format Int: The new PixelFormat of the surface. Value is android.graphics.PixelFormat#RGBA_8888, android.graphics.PixelFormat#RGBX_8888, android.graphics.PixelFormat#RGBA_F16, android.graphics.PixelFormat#RGBA_1010102, android.graphics.PixelFormat#RGB_888, android.graphics.PixelFormat#RGB_565, or android.graphics.PixelFormat.R_8
width Int: The new width of the surface. Value is 0 or greater
height Int: The new height of the surface. Value is 0 or greater

surfaceCreated

Added in API level 9
open fun surfaceCreated(holder: SurfaceHolder): Unit
Parameters
holder SurfaceHolder: The SurfaceHolder whose surface is being created. This value cannot be null.

surfaceDestroyed

Added in API level 9
open fun surfaceDestroyed(holder: SurfaceHolder): Unit
Parameters
holder SurfaceHolder: The SurfaceHolder whose surface is being destroyed. This value cannot be null.

surfaceRedrawNeeded

Added in API level 9
open fun surfaceRedrawNeeded(holder: SurfaceHolder): Unit
Parameters
holder SurfaceHolder: The SurfaceHolder whose surface has changed. This value cannot be null.

Protected methods

onCreate

Added in API level 9
protected open fun onCreate(savedInstanceState: Bundle?): Unit
Parameters
savedInstanceState Bundle?: If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in #onSaveInstanceState. Note: Otherwise it is null.

onDestroy

Added in API level 9
protected open fun onDestroy(): Unit

onPause

Added in API level 9
protected open fun onPause(): Unit

onResume

Added in API level 9
protected open fun onResume(): Unit

onSaveInstanceState

Added in API level 9
protected open fun onSaveInstanceState(outState: Bundle): Unit
Parameters
outState Bundle: Bundle in which to place your saved state. This value cannot be null.

onStart

Added in API level 9
protected open fun onStart(): Unit

onStop

Added in API level 9
protected open fun onStop(): Unit