public class SGAgent
extends Object
SGAgent is the main class of SGUtil library. Before using it, you need to create an instance of the class and calling its method onCreate to do initialization. As a hint from the name, this method should be called in onCreate of application's main Activity. Besides onCreate, its methods with the same names as primary Android Activity lifecycle callbacks should be called (in callbacks) too. Please find details in the description of those methods. SGAgent takes the main Activity of application as a client, which should implement SGAgent.SGClient interface.
SGAgent manages user login state, information retrieval state and product purchase state in its state machines. Execution of its methods may lead to change of these states. You can override SGClient.onStateChange to monitor these changes and make proper processing. The state transfer and corresponding processing are listed in the table below.
Transfer of user login state
Old state | New state | Transfer operation | Transfer cause |
---|---|---|---|
USRSTATE_IDLE | USRSTATE_INITIALIZING | OP_INIT | Initialization: agent.onCreate() |
USRSTATE_INITIALIZING | USRSTATE_INITIALIZED | OP_INIT | Initialization succeeded |
USRSTATE_INITIALIZING | USRSTATE_IDLE | OP_INIT | Initialization failed |
USRSTATE_INITIALIZED | USRSTATE_LOGINING | OP_LOGIN | Channel login: agent.login() |
USRSTATE_LOGINING | USRSTATE_LOGINED | OP_LOGIN | Channel login succeeded |
USRSTATE_LOGINING | USRSTATE_INITIALIZED | OP_LOGIN | Channel login failed |
USRSTATE_LOGINED | USRSTATE_AUTHING | OP_AUTH | Channel login verification (auto) |
USRSTATE_AUTHING | USRSTATE_AUTHED | OP_AUTH | Channel login verification succeeded |
USRSTATE_AUTHING | USRSTATE_INITIALIZED | OP_AUTH | Channel login verification failed |
USRSTATE_AUTHED | USRSTATE_LOGININGGAME | OP_LOGINGAME | Game server login (auto) |
USRSTATE_LOGININGGAME | USRSTATE_LOGINEDGAME | OP_LOGINGAME | Game server login succeeded |
USRSTATE_LOGININGGAME | USRSTATE_INITIALIZED | OP_LOGINGAME | Game server login failed |
USRSTATE_LOGINEDGAME | USRSTATE_LOGOUTINGGAME | OP_LOGOUTGAME | Game server logout: agent.logout() |
USRSTATE_LOGOUTINGGAME | USRSTATE_LOGOUTEDGAME | OP_LOGOUTGAME | Game server logout succeeded |
USRSTATE_LOGOUTINGGAME | USRSTATE_LOGINEDGAME | OP_LOGOUTGAME | Game server logout failed |
USRSTATE_LOGOUTEDGAME | USRSTATE_LOGOUTING | OP_LOGOUT | Channel logout (auto) |
USRSTATE_LOGOUTING | USRSTATE_INITIALIZED | OP_LOGOUT | Channel logout (no matter) succeeded or failed |
USRSTATE_LOGOUTED (Not used) | |||
USRSTATE_ERROR (Not used) |
Transfer of information retrieval state
Old state | New state | Transfer operation | Transfer cause) |
---|---|---|---|
JOBSTATE_IDLE | JOBSTATE_REQUESTINGSTARTGAME | OP_STARTGAME | Start game: agent.startGame() |
JOBSTATE_REQUESTINGSTARTGAME | JOBSTATE_IDLE | OP_STARTGAME | finished starting game (no matter) succeeded or failed |
JOBSTATE_IDLE | JOBSTATE_REQUESTINGSTOPGAME | OP_STOPGAME | Stop game: agent.stopGame() |
JOBSTATE_REQUESTINGSTOPGAME | JOBSTATE_IDLE | OP_STOPGAME | finished stopping game (no matter) succeeded or failed |
JOBSTATE_IDLE | JOBSTATE_GETTINGPRODUCTS | OP_GETPRODUCTS | Product list retrieval: agent.getProducts() |
JOBSTATE_GETTINGPRODUCTS | JOBSTATE_IDLE | OP_GETPRODUCTS | Product list retrieval (no matter) succeeded or failed |
JOBSTATE_IDLE | JOBSTATE_GETTINGORDERINFOLIST | OP_GETORDERINFOLIST | Order info list retrieval: agent.getOrderInfoList() |
JOBSTATE_GETTINGORDERINFOLIST | JOBSTATE_IDLE | OP_GETORDERINFOLIST | Order info list retrieval (no matter) succeeded or failed |
JOBSTATE_IDLE | JOBSTATE_GETTINGTREASURELIST | OP_GETTREASURELIST | Treasure list retrieval: agent.getTreasureList() |
JOBSTATE_GETTINGTREASURELIST | JOBSTATE_IDLE | OP_GETTREASURELIST | Treasure list retrieval (no matter) succeeded or failed |
JOBSTATE_IDLE | JOBSTATE_INCINGTREASURE | OP_INCTREASURE | Increase treasure count: agent.incTreasure() |
JOBSTATE_INCINGTREASURE | JOBSTATE_IDLE | OP_INCTREASURE | Increase treasure count (no matter) succeeded or failed |
JOBSTATE_IDLE | JOBSTATE_GETTINGLOGVALUE | OP_GETLOGVALUE | Get value of logged key: agent.getLogValue() |
JOBSTATE_GETTINGLOGVALUE | JOBSTATE_IDLE | OP_GETLOGVALUE | Get value of logged key (no matter) succeeded or failed |
JOBSTATE_GOTPRODUCTS (Not used) | |||
JOBSTATE_GOTORDERINFOLIST (Not used) | |||
JOBSTATE_GOTLOGVALUE (Not used) | |||
JOBSTATE_ERROR (Not used) |
Transfer of product purchase state
Old state | New state | Transfer operation | Transfer cause |
---|---|---|---|
PAYSTATE_IDLE | PAYSTATE_GETTINGORDER | OP_GETORDER | Initiate purchase agent.buyProduct() |
PAYSTATE_GETTINGORDER | PAYSTATE_IDLE | OP_GETORDER | Order generation failed |
PAYSTATE_GETTINGORDER | PAYSTATE_GOTORDER | OP_GETORDER | Order generation succeeded |
PAYSTATE_GOTORDER | PAYSTATE_PAYING | OP_PAY | Start channel payment operation (auto) |
PAYSTATE_PAYING | PAYSTATE_IDLE | OP_PAY | Channel payment operation failed or cancelled |
PAYSTATE_PAYING | PAYSTATE_PAID | OP_PAY | Channel payment operation succeeded (only UI operation succeeded, backend (server) verification is necessary) |
PAYSTATE_PAID | PAYSTATE_GETTINGORDERSTATE | OP_GETORDERSTATE | Check whether money was received (might be auto, refer to setOrderStateCheckingIntervals) |
PAYSTATE_GETTINGORDERSTATE | PAYSTATE_IDLE | OP_GETORDERSTATE | Payment failed or money is not enough (refer to getState) |
PAYSTATE_GETTINGORDERSTATE | PAYSTATE_ORDERSUCCEEDED | OP_GETORDERSTATE | Payment succeeded |
PAYSTATE_ORDERSUCCEEDED | PAYSTATE_DLVINGORDER | OP_DLVORDER | Changing game server order state to delivered |
PAYSTATE_DLVINGORDER | PAYSTATE_IDLE | OP_DLVORDER | Game server order could not be changed |
PAYSTATE_ERROR (Not used) |
Modifier and Type | Class and Description |
---|---|
static interface |
SGAgent.SGClient
SGClient interface.
|
Modifier and Type | Field and Description |
---|---|
static int |
EXT_PROP_ARGS
Extended function need arguments.
|
static int |
EXT_PROP_ASYNC
Extended function is asynchronous.
|
static int |
EXT_PROP_LOGIN
Extended function only effective after login.
|
static int |
EXT_PROP_NONLOGIN
Extended function only effective before login.
|
static int |
EXT_PROP_VOID
Extended function returns void.
|
static int |
EXT_RET_CANCELLED
Asynchronous extended function cancelled.
|
static int |
EXT_RET_ERROR
Asynchronous extended function failed.
|
static int |
EXT_RET_OK
Asynchronous extended function succeeded.
|
static String |
EXTMETHOD_RET_PREFIX_BAD_CMD |
static String |
EXTMETHOD_RET_PREFIX_EMPTY_CMDLINE |
static String |
EXTMETHOD_RET_PREFIX_LOGIN |
static String |
EXTMETHOD_RET_PREFIX_NO_COOKIE |
static String |
EXTMETHOD_RET_PREFIX_NONLOGIN |
static String |
EXTMETHOD_RET_PREFIX_NULL |
static String |
EXTMETHOD_RET_PREFIX_NULL_ASYNC |
static String |
EXTMETHOD_RET_PREFIX_STRING |
static String |
EXTMETHOD_RET_PREFIX_STRING_ASYNC |
static String |
EXTMETHOD_RET_PREFIX_VOID |
static String |
EXTMETHOD_RET_PREFIX_VOID_ASYNC |
static int |
JOBSTATE_ERROR
Information retrieval state: Error
|
static int |
JOBSTATE_GETTINGLOGVALUE
Information retrieval state: Increasing treasure count
|
static int |
JOBSTATE_GETTINGORDERINFOLIST
Information retrieval state: Retrieving order info list
|
static int |
JOBSTATE_GETTINGPLAYERDETAILS
Information retrieval state: Getting player details
|
static int |
JOBSTATE_GETTINGPRODUCTS
Information retrieval state: Retrieving product list
|
static int |
JOBSTATE_GETTINGTREASURELIST
Information retrieval state: Retrieving treasure list
|
static int |
JOBSTATE_GOTPLAYERDETAILS
Information retrieval state: Got player details
|
static int |
JOBSTATE_IDLE
Information retrieval state: Idle
|
static int |
JOBSTATE_INCINGTREASURE
Information retrieval state: Increasing treasure count
|
static int |
JOBSTATE_REQUESTEDSTARTGAME
Information retrieval state: Starting game request processed
|
static int |
JOBSTATE_REQUESTEDSTOPGAME
Information retrieval state: Stopping game request processed
|
static int |
JOBSTATE_REQUESTINGSTARTGAME
Information retrieval state: Requesting to start game
|
static int |
JOBSTATE_REQUESTINGSTOPGAME
Information retrieval state: Requesting to stop game
|
static int |
JOBSTATE_SHAREDSCREEN
Information retrieval state: Shared screen
|
static int |
JOBSTATE_SHARINGSCREEN
Information retrieval state: Sharing screen
|
static int |
OP_AUTH
Channel login verification
|
static int |
OP_DLVORDER
Marking as delivered
|
static int |
OP_GETLOGVALUE
Get value of remote log key
|
static int |
OP_GETORDER
Order generation
|
static int |
OP_GETORDERINFOLIST
Order info list retrieval
|
static int |
OP_GETORDERSTATE
Order state retrieval
|
static int |
OP_GETPLAYERDETAILS
Get player details
|
static int |
OP_GETPRODUCTS
Product list retrieval
|
static int |
OP_GETTREASURELIST
Order info list retrieval
|
static int |
OP_INCTREASURE
Increase treasure count
|
static int |
OP_INIT
Initialization
|
static int |
OP_LOGIN
Channel login
|
static int |
OP_LOGINGAME
Game server login
|
static int |
OP_LOGOUT
Channel logout
|
static int |
OP_LOGOUTGAME
Game server logout
|
static int |
OP_NONE
No operation
|
static int |
OP_PAY
Pay
|
static int |
OP_SHARESCREEN
Share screen
|
static int |
OP_STARTGAME
Start game
|
static int |
OP_STOPGAME
Stop game
|
static int |
PAYSTATE_DLVINGORDER
Product purchase state: Delivering product
|
static int |
PAYSTATE_ERROR
Product purchase state: Error
|
static int |
PAYSTATE_GETTINGORDER
Product purchase state: Order is being generated
|
static int |
PAYSTATE_GETTINGORDERSTATE
Product purchase state: Retrieving order state
|
static int |
PAYSTATE_GOTORDER
Product purchase state: Order generated
|
static int |
PAYSTATE_IDLE
Product purchase state: Idle
|
static int |
PAYSTATE_ORDERSUCCEEDED
Product purchase state: Payment succeeded
|
static int |
PAYSTATE_PAID
Product purchase state: Payment UI operation succeeded
|
static int |
PAYSTATE_PAYING
Product purchase state: Payment UI operation ongoing
|
static int |
STATE_CHANGE_REASON_NONE
Reason of state change: None
|
static int |
STATE_CHANGE_REASON_OP
Reason of state change: An operation was performed
|
static int |
STATE_CHANGE_REASON_OP_CANCELED
Reason of state change: Operation cancelled
|
static int |
STATE_CHANGE_REASON_OP_FAILURE
Reason of state change: Operation failed
|
static int |
STATE_CHANGE_REASON_OP_SUCCESS
Reason of state change: Operation succeeded
|
static int |
STATE_TYPE_JOB
Information retrieval state
|
static int |
STATE_TYPE_PAY
Product purchase
|
static int |
STATE_TYPE_USR
User login state
|
static int |
USRSTATE_AUTHED
User login state: Verified channel login information
|
static int |
USRSTATE_AUTHING
User login state: Verifying channel login information
|
static int |
USRSTATE_ERROR
User login state: Error
|
static int |
USRSTATE_IDLE
User login state: Idle
|
static int |
USRSTATE_INITIALIZED
User login state: Initialized
|
static int |
USRSTATE_INITIALIZING
User login state: Initializing
|
static int |
USRSTATE_LOGINED
User login state: Logined to channel
|
static int |
USRSTATE_LOGINEDGAME
User login state: Logined to game server
|
static int |
USRSTATE_LOGINING
User login state: Logining to channel
|
static int |
USRSTATE_LOGININGGAME
User login state: Logining to game server
|
static int |
USRSTATE_LOGOUTED
User login state: Logouted from channel
|
static int |
USRSTATE_LOGOUTEDGAME
User login state: Logouted from game server
|
static int |
USRSTATE_LOGOUTING
User login state: Logouting from channel
|
static int |
USRSTATE_LOGOUTINGGAME
User login state: Logouting from game server
|
Constructor and Description |
---|
SGAgent() |
Modifier and Type | Method and Description |
---|---|
boolean |
buyProduct(String productID,
int num,
String treasure)
Initiate product purchase.
|
void |
exit()
Exit application.
|
UAccount |
getAccount()
Get final account.
|
int |
getApkVersionCode()
Get version code.
|
String |
getApkVersionName()
Get version name.
|
int |
getAppID()
Get application ID.
|
String |
getAppKey()
Get application key.
|
Map<String,String> |
getChannelConfigs()
Get channel config items.
|
int |
getChannelID()
Get channel ID.
|
String |
getChannelName()
Get channel short name.
|
String |
getDeviceID()
Get device ID.
|
SGGameServerInterface |
getGameServer()
Get current game server instance.
|
int |
getJobState()
Get information retrieval state.
|
Map<String,String> |
getLoginExtensionMap() |
boolean |
getLogValue(String key,
int defaultValue)
Start progress to get value of remote log key.
|
String |
getOpName(int op)
Get name of operation, for readable debug output.
|
boolean |
getOrderInfoList(String filter)
Start order info list retrieval progress.
|
boolean |
getOrderState(String orderID)
Start payment result retrieval progress.
|
int |
getPayState()
Get product purchase state.
|
boolean |
getPlayerDetails()
Get player details.
|
UProduct |
getProductByOrderID(String orderID)
Find product corresponding to specified order ID.
|
boolean |
getProducts(String filter,
boolean sorting)
Start product list retrieval progress.
|
USession |
getSession()
Get session.
|
String |
getStateChangeReasonName(int reason)
Get name of state change reason, for readable debug output.
|
String |
getStateName(int type,
int state)
Get name of state, for readable debug output.
|
String |
getStateTypeName(int type)
Get name of state type, for readable debug output.
|
String |
getSubChannelName()
Get name of sub-channel.
|
boolean |
getTreasureList(String filter)
Start treasure list retrieval progress.
|
int |
getUsrState()
Get user login state.
|
boolean |
incTreasure(String name,
int value)
Start progress to increase treasure.
|
boolean |
log(char action,
String key,
int value,
String message)
Remote logging.
|
boolean |
login()
Start login progress.
|
boolean |
logout()
Start logout progress.
|
void |
notifyFuncRequestResult(String func,
String id,
String result)
Notify result of function request.
|
void |
onActivityResult(int requestCode,
int resultCode,
Intent data)
Called in onActivityResult callback of main Activity.
|
void |
onBackPressed()
Called in onBackPressed callback of main Activity.
|
void |
onCreate(Activity activity,
SGAgent.SGClient client)
Initalize SGUtil library.
|
void |
onDestroy()
Called in onDestroy callback of main Activity.
|
boolean |
onKeyDown(int keyCode,
KeyEvent event)
Called in onKeyDown callback of main Activity.
|
void |
onNewIntent(Intent newIntent)
Called in onNewIntent callback of main Activity.
|
void |
onPause()
Called in onPause callback of main Activity.
|
void |
onRequestPermissionsResult(int requestCode,
String[] permissions,
int[] grantResults)
Called in onRequestPermissionsResult callback of main Activity.
|
void |
onRestart()
Called in onRestart callback of main Activity.
|
void |
onResume()
Called in onResume callback of main Activity.
|
void |
onStart()
Called in onStart callback of main Activity.
|
void |
onStop()
Called in onStop callback of main Activity.
|
boolean |
recover(String recoverToken)
Start recover progress.
|
String |
runExtMethod(String cookie,
String cmdLine)
Run extended function.
|
void |
setGameServer(SGGameServerInterface gs,
Map<String,String> params)
Set game server instance.
|
void |
setOrderStateCheckingIntervals(int[] intervals)
Set intervals in milliseconds to wait before starting automatic result query
(after order payment is successfully submitted to channel -- that is, the payment UI operation succeeded).
|
boolean |
setStartupParams(String paramString) |
boolean |
shareScreen(String imageFile,
String title,
String content)
Share screen.
|
boolean |
startGame()
Request to start game.
|
boolean |
stopGame()
Request to stop game.
|
void |
wantOrderInfo()
Request SGAgent to send next order info via onOrderInfoBegin.
|
void |
wantProduct()
Request SGAgent to send next product info via onProductFound.
|
public static final int EXT_PROP_ARGS
public static final int EXT_PROP_ASYNC
public static final int EXT_PROP_LOGIN
public static final int EXT_PROP_NONLOGIN
public static final int EXT_PROP_VOID
public static final int EXT_RET_CANCELLED
public static final int EXT_RET_ERROR
public static final int EXT_RET_OK
public static final String EXTMETHOD_RET_PREFIX_BAD_CMD
public static final String EXTMETHOD_RET_PREFIX_EMPTY_CMDLINE
public static final String EXTMETHOD_RET_PREFIX_LOGIN
public static final String EXTMETHOD_RET_PREFIX_NO_COOKIE
public static final String EXTMETHOD_RET_PREFIX_NONLOGIN
public static final String EXTMETHOD_RET_PREFIX_NULL
public static final String EXTMETHOD_RET_PREFIX_NULL_ASYNC
public static final String EXTMETHOD_RET_PREFIX_STRING
public static final String EXTMETHOD_RET_PREFIX_STRING_ASYNC
public static final String EXTMETHOD_RET_PREFIX_VOID
public static final String EXTMETHOD_RET_PREFIX_VOID_ASYNC
public static final int JOBSTATE_ERROR
public static final int JOBSTATE_GETTINGLOGVALUE
public static final int JOBSTATE_GETTINGORDERINFOLIST
public static final int JOBSTATE_GETTINGPLAYERDETAILS
public static final int JOBSTATE_GETTINGPRODUCTS
public static final int JOBSTATE_GETTINGTREASURELIST
public static final int JOBSTATE_GOTPLAYERDETAILS
public static final int JOBSTATE_IDLE
public static final int JOBSTATE_INCINGTREASURE
public static final int JOBSTATE_REQUESTEDSTARTGAME
public static final int JOBSTATE_REQUESTEDSTOPGAME
public static final int JOBSTATE_REQUESTINGSTARTGAME
public static final int JOBSTATE_REQUESTINGSTOPGAME
public static final int JOBSTATE_SHAREDSCREEN
public static final int JOBSTATE_SHARINGSCREEN
public static final int OP_AUTH
public static final int OP_DLVORDER
public static final int OP_GETLOGVALUE
public static final int OP_GETORDER
public static final int OP_GETORDERINFOLIST
public static final int OP_GETORDERSTATE
public static final int OP_GETPLAYERDETAILS
public static final int OP_GETPRODUCTS
public static final int OP_GETTREASURELIST
public static final int OP_INCTREASURE
public static final int OP_INIT
public static final int OP_LOGIN
public static final int OP_LOGINGAME
public static final int OP_LOGOUT
public static final int OP_LOGOUTGAME
public static final int OP_NONE
public static final int OP_PAY
public static final int OP_SHARESCREEN
public static final int OP_STARTGAME
public static final int OP_STOPGAME
public static final int PAYSTATE_DLVINGORDER
public static final int PAYSTATE_ERROR
public static final int PAYSTATE_GETTINGORDER
public static final int PAYSTATE_GETTINGORDERSTATE
public static final int PAYSTATE_GOTORDER
public static final int PAYSTATE_IDLE
public static final int PAYSTATE_ORDERSUCCEEDED
public static final int PAYSTATE_PAID
public static final int PAYSTATE_PAYING
public static final int STATE_CHANGE_REASON_NONE
public static final int STATE_CHANGE_REASON_OP
public static final int STATE_CHANGE_REASON_OP_CANCELED
public static final int STATE_CHANGE_REASON_OP_FAILURE
public static final int STATE_CHANGE_REASON_OP_SUCCESS
public static final int STATE_TYPE_JOB
public static final int STATE_TYPE_PAY
public static final int STATE_TYPE_USR
public static final int USRSTATE_AUTHED
public static final int USRSTATE_AUTHING
public static final int USRSTATE_ERROR
public static final int USRSTATE_IDLE
public static final int USRSTATE_INITIALIZED
public static final int USRSTATE_INITIALIZING
public static final int USRSTATE_LOGINED
public static final int USRSTATE_LOGINEDGAME
public static final int USRSTATE_LOGINING
public static final int USRSTATE_LOGININGGAME
public static final int USRSTATE_LOGOUTED
public static final int USRSTATE_LOGOUTEDGAME
public static final int USRSTATE_LOGOUTING
public static final int USRSTATE_LOGOUTINGGAME
public boolean buyProduct(String productID, int num, String treasure)
productID
- product IDnum
- copied to buy, should be 1 at presentpublic void exit()
public UAccount getAccount()
public int getApkVersionCode()
public String getApkVersionName()
public int getAppID()
public String getAppKey()
public Map<String,String> getChannelConfigs()
public int getChannelID()
public String getChannelName()
public String getDeviceID()
public SGGameServerInterface getGameServer()
public int getJobState()
public Map<String,String> getLoginExtensionMap()
public boolean getLogValue(String key, int defaultValue)
key
- key to matchdefaultValue
- default value to return in case of failurepublic String getOpName(int op)
op
- operation codepublic boolean getOrderInfoList(String filter)
filter
- a string to be passed to game server as a query item in URL, may be used for a filter.public boolean getOrderState(String orderID)
orderID
- order IDpublic int getPayState()
public boolean getPlayerDetails()
public UProduct getProductByOrderID(String orderID)
orderID
- order IDpublic boolean getProducts(String filter, boolean sorting)
filter
- string to be passed to game server as a query item in URL, may be used as a filter.sorting
- specify whether sort the products or not. Sorting criteria is product price and coins.public USession getSession()
public String getStateChangeReasonName(int reason)
reason
- state change reason. One of STATE_CHANGE_REASON_NONE
, STATE_CHANGE_REASON_OP
,
STATE_CHANGE_REASON_OP_SUCCESS
, STATE_CHANGE_REASON_OP_FAILURE
and
STATE_CHANGE_REASON_OP_CANCELED
.public String getStateName(int type, int state)
type
- state type. One of STATE_TYPE_USR
, STATE_TYPE_JOB
and STATE_TYPE_PAY
.state
- statepublic String getStateTypeName(int type)
type
- state type. One of STATE_TYPE_USR
, STATE_TYPE_JOB
and STATE_TYPE_PAY
.public String getSubChannelName()
public boolean getTreasureList(String filter)
filter
- filter stringpublic int getUsrState()
public boolean incTreasure(String name, int value)
public boolean log(char action, String key, int value, String message)
action
- action codekey
- used to match (and update) existing record with the same keyvalue
- integer valuemessage
- additional informationpublic boolean login()
public boolean logout()
public void notifyFuncRequestResult(String func, String id, String result)
func
- Function name.id
- Function ID.result
- Result. One of "succeeded", "failed" and "cancelled".public void onActivityResult(int requestCode, int resultCode, Intent data)
requestCode
- Android standard parameterresultCode
- Android standard parameterdata
- Android standard parameterpublic void onBackPressed()
public void onCreate(Activity activity, SGAgent.SGClient client)
activity
- main Activityclient
- object that implemented SGClient interfacepublic void onDestroy()
public boolean onKeyDown(int keyCode, KeyEvent event)
keyCode
- Android standard parameterevent
- Android standard parameterpublic void onNewIntent(Intent newIntent)
newIntent
- Android standard parameterpublic void onPause()
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
requestCode
- Android standard parameterpermissions
- Android standard parametergrantResults
- Android standard parameterpublic void onRestart()
public void onResume()
public void onStart()
public void onStop()
public boolean recover(String recoverToken)
public String runExtMethod(String cookie, String cmdLine)
Format | Meaning |
---|---|
? | Display all methods in format methodName=flags. |
?* | Display all methods in format String methodName(String cookie, String ... args). |
? methodName | Display specified method in format methodName=flags. |
?* methodName | Display specified method in format String methodName(String cookie, String ... args). |
methodName | Run method without arguments |
methodName arg0 arg1 ... | Run method with arguments |
methodName cookie | Run asynchronous method without arguments |
methodName cookie arg0 arg1 ... | Run asynchronous method with arguments |
Asynchronous notification is delivered via SGClient.onExtMethodNotification.
Refer to DocumentWorkspace for channel individual description.
cookie
- string used as cookie for asynchronous methodcmdLine
- command linepublic void setGameServer(SGGameServerInterface gs, Map<String,String> params)
gs
- Instance of game server interface implementationparams
- Parameters to be passed to method SGGameServerInterface.inipublic void setOrderStateCheckingIntervals(int[] intervals)
intervals
- Time intervals in milliseconds. Wait intervals[0] milliseconds before first query, intervals[1] milliseconds
before second query, and so on, until query succeeds.
Automatic query is given up if all intervals is run out.
Automatic query is not performed if intervals is null or an empty array. You should call getOrderState
to start query manually in this case.
Other function cannot be executed during the automatic query period. If you think it a problem, please set intervals to null
and call getOrderState to start query by yourself.public boolean setStartupParams(String paramString)
public boolean shareScreen(String imageFile, String title, String content)
imageFile
- path of image to share.title
- Title.content
- Content of description.public boolean startGame()
public boolean stopGame()
public void wantOrderInfo()
public void wantProduct()