GameState


public final class GameState
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.GameState


State of the game passed to the GameManager. This includes a top-level state for the game (indicating if the game can be interrupted without interfering with content that can't be paused). Since content can be loaded in any state, it includes an independent boolean flag to indicate loading status. Free-form metadata (as a Bundle) and a string description can also be specified by the application.

Summary

Constants

int MODE_CONTENT

Indicates that the current content shown is not gameplay related.

int MODE_GAMEPLAY_INTERRUPTIBLE

Indicates if the game is in active, but interruptible, game play.

int MODE_GAMEPLAY_UNINTERRUPTIBLE

Indicates if the game is in active user play mode, which is real time and cannot be interrupted.

int MODE_NONE

No mode means that the game is not in active play, for example the user is using the game menu.

int MODE_UNKNOWN

Default Game mode is unknown.

Inherited constants

Fields

public static final Creator<GameState> CREATOR

Implement the parcelable interface.

Public constructors

GameState(boolean isLoading, int mode)

Create a GameState with the specified loading status.

GameState(boolean isLoading, int mode, int label, int quality)

Create a GameState with the given state variables.

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getLabel()
int getMode()
int getQuality()
boolean isLoading()
void writeToParcel(Parcel parcel, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

MODE_CONTENT

Added in API level 33
public static final int MODE_CONTENT

Indicates that the current content shown is not gameplay related. For example it can be an ad, a web page, a text, or a video.

Constant Value: 4 (0x00000004)

MODE_GAMEPLAY_INTERRUPTIBLE

Added in API level 33
public static final int MODE_GAMEPLAY_INTERRUPTIBLE

Indicates if the game is in active, but interruptible, game play.

Constant Value: 2 (0x00000002)

MODE_GAMEPLAY_UNINTERRUPTIBLE

Added in API level 33
public static final int MODE_GAMEPLAY_UNINTERRUPTIBLE

Indicates if the game is in active user play mode, which is real time and cannot be interrupted.

Constant Value: 3 (0x00000003)

MODE_NONE

Added in API level 33
public static final int MODE_NONE

No mode means that the game is not in active play, for example the user is using the game menu.

Constant Value: 1 (0x00000001)

MODE_UNKNOWN

Added in API level 33
public static final int MODE_UNKNOWN

Default Game mode is unknown.

Constant Value: 0 (0x00000000)

Fields

CREATOR

Added in API level 33
public static final Creator<GameState> CREATOR

Implement the parcelable interface.

Public constructors

GameState

Added in API level 33
public GameState (boolean isLoading, 
                int mode)

Create a GameState with the specified loading status.

Parameters
isLoading boolean: Whether the game is in the loading state.

mode int: The game state mode of type @GameStateMode. Value is MODE_UNKNOWN, MODE_NONE, MODE_GAMEPLAY_INTERRUPTIBLE, MODE_GAMEPLAY_UNINTERRUPTIBLE, or MODE_CONTENT

GameState

Added in API level 33
public GameState (boolean isLoading, 
                int mode, 
                int label, 
                int quality)

Create a GameState with the given state variables.

Parameters
isLoading boolean: Whether the game is in the loading state.

mode int: The game state mode. Value is MODE_UNKNOWN, MODE_NONE, MODE_GAMEPLAY_INTERRUPTIBLE, MODE_GAMEPLAY_UNINTERRUPTIBLE, or MODE_CONTENT

label int: An optional developer-supplied enum e.g. for the current level.

quality int: An optional developer-supplied enum, e.g. for the current quality level.

Public methods

describeContents

Added in API level 33
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getLabel

Added in API level 33
public int getLabel ()

Returns
int The developer-supplied enum, e.g. to indicate level or scene. The default value (if not supplied) is -1.

getMode

Added in API level 33
public int getMode ()

Returns
int The game state mode. Value is MODE_UNKNOWN, MODE_NONE, MODE_GAMEPLAY_INTERRUPTIBLE, MODE_GAMEPLAY_UNINTERRUPTIBLE, or MODE_CONTENT

getQuality

Added in API level 33
public int getQuality ()

Returns
int The developer-supplied enum, e.g. to indicate the current quality level. The default value (if not suplied) is -1.

isLoading

Added in API level 33
public boolean isLoading ()

Returns
boolean If the game is loading assets/resources/compiling/etc.

writeToParcel

Added in API level 33
public void writeToParcel (Parcel parcel, 
                int flags)

Flatten this object in to a Parcel.

Parameters
parcel Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES