当前位置: 首页>>代码示例>>Java>>正文


Java AppStateClient类代码示例

本文整理汇总了Java中com.google.android.gms.appstate.AppStateClient的典型用法代码示例。如果您正苦于以下问题:Java AppStateClient类的具体用法?Java AppStateClient怎么用?Java AppStateClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AppStateClient类属于com.google.android.gms.appstate包,在下文中一共展示了AppStateClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAppStateClient

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
/**
 * Returns the AppStateClient object. In order to call this method, you must have
 * called @link{#setup} with a set of clients that includes CLIENT_APPSTATE.
 */
public AppStateClient getAppStateClient() {
    if (mAppStateClient == null) {
        throw new IllegalStateException("No AppStateClient. Did you request it at setup?");
    }
    return mAppStateClient;
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:11,代码来源:GameHelper.java

示例2: start

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
public static void start(Context ctx)
{
  gamesClient = new GamesClient.Builder(ctx,
      new GooglePlayCallback("GAMES_CLIENT"),
      new GooglePlayCallback("GAMES_CLIENT"))
    .setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL)
    .setScopes(Scopes.GAMES)
    .create();

  appStateClient = new AppStateClient.Builder(ctx,
      new GooglePlayCallback("APP_STATE_CLIENT"),
      new GooglePlayCallback("APP_STATE_CLIENT"))
    .setScopes(Scopes.APP_STATE)
    .create();
}
 
开发者ID:sergey-miryanov,项目名称:ExtensionsPack,代码行数:16,代码来源:GooglePlay.java

示例3: onStateLoaded

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
@Override
public void onStateLoaded(int statusCode, int stateKey, byte[] data) {
	LevelManager levelManager = mActivity.getGame().getLevelManager();
	
	switch (statusCode) {
	case AppStateClient.STATUS_OK:
		ByteBuffer buffer = ByteBuffer.wrap(data);
		levelManager.setCurrentCampaignLevel(buffer.getInt());
		levelManager.setCampaignScore(buffer.getInt());
		break;		
	default:
		levelManager.setCurrentCampaignLevel(0);
		levelManager.setCampaignScore(0);
	}
}
 
开发者ID:dbaelz,项目名称:Secludedness,代码行数:16,代码来源:AndroidGPGSManager.java

示例4: getAppStateClient

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
/**
* Returns the AppStateClient object. In order to call this method, you must have
* called @link{#setup} with a set of clients that includes CLIENT_APPSTATE.
*/
public AppStateClient getAppStateClient() {
    if (mAppStateClient == null) {
        throw new IllegalStateException("No AppStateClient. Did you request it at setup?");
    }
    return mAppStateClient;
}
 
开发者ID:ldarren,项目名称:pico-phonegap-base,代码行数:11,代码来源:GmsHelper.java

示例5: onStateDeleted

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
@Override
public void onStateDeleted(int statusCode, int stateKey){
    JSONObject json = new JSONObject();
    try{
        json.put("type", STATE_CONFLICTED);
        json.put("statusCode", statusCode);
        json.put("stateKey", stateKey);
        switch (statusCode) {
            case AppStateClient.STATUS_OK:
                // if data was successfully deleted from the server.
                break;        
            case AppStateClient.STATUS_INTERNAL_ERROR:
                // if an unexpected error occurred in the service 
                break;
            case AppStateClient.STATUS_NETWORK_ERROR_OPERATION_FAILED:
                // if the device was unable to communicate with the network. In this case, the operation is not retried automatically.
                break;
            case AppStateClient.STATUS_CLIENT_RECONNECT_REQUIRED:
                // need to reconnect AppStateClient
                mHelper.reconnectClients(clientTypes);
                break;
            default:
                // error
                break;
        }
    }catch(JSONException ex){
        Log.e(TAG, "STATE_DELETED ["+statusCode+"] ["+stateKey+"] exception: "+ex.getMessage());
        return;
    }

    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, json);
    pluginResult.setKeepCallback(true);
    connectionCB.sendPluginResult(pluginResult);
}
 
开发者ID:ldarren,项目名称:pico-phonegap-base,代码行数:35,代码来源:PlayServices.java

示例6: getAppStateClient

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
protected AppStateClient getAppStateClient() {
    return mHelper.getAppStateClient();
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:4,代码来源:BaseGameActivity.java

示例7: getAppStateClient

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
protected AppStateClient getAppStateClient() 
{
    return mHelper.getAppStateClient();
}
 
开发者ID:Lunarsong,项目名称:NativeActivity,代码行数:5,代码来源:BaseGameActivity.java

示例8: onStateLoaded

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
@Override           
public void onStateLoaded(int statusCode, int stateKey, byte[] localData) {
    JSONObject json = new JSONObject();
    try{
        json.put("type", STATE_LOADED);
        json.put("status", statusCode);
        switch (statusCode) {
            case AppStateClient.STATUS_OK:
                // Data was successfully loaded from the cloud: merge with local data.
                json.put("stateKey", stateKey);
                json.put("data", new String(localData));
                break;        
            case AppStateClient.STATUS_STATE_KEY_NOT_FOUND:
                // key not found means there is no saved data. To us, this is the same as
                // having empty data, so we treat this as a success.
                break;
            case AppStateClient.STATUS_STATE_KEY_LIMIT_EXCEEDED:
                // if the application already has data present in the maximum number of state keys.
                break;
            case AppStateClient.STATUS_NETWORK_ERROR_NO_DATA:
                // can't reach cloud, and we have no local state. Warn user that
                // they may not see their existing progress, but any new progress won't be lost.
                break;
            case AppStateClient.STATUS_NETWORK_ERROR_STALE_DATA:
                // can't reach cloud, but we have locally cached data.
                break;
            case AppStateClient.STATUS_CLIENT_RECONNECT_REQUIRED:
                // need to reconnect AppStateClient
                mHelper.reconnectClients(clientTypes);
                break;
            case AppStateClient.STATUS_INTERNAL_ERROR:
                // if an unexpected error occurred in the service.
                break;
            default:
                // error
                break;
        }
    }catch(JSONException ex){
        Log.e(TAG, "STATE_LOADED ["+statusCode+"] ["+stateKey+"] exception: "+ex.getMessage());
        return;
    }

    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, json);
    pluginResult.setKeepCallback(true);
    connectionCB.sendPluginResult(pluginResult);
}
 
开发者ID:ldarren,项目名称:pico-phonegap-base,代码行数:47,代码来源:PlayServices.java

示例9: onStateListLoaded

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
@Override
public void onStateListLoaded(int statusCode, AppStateBuffer buffer) {
    JSONObject json = new JSONObject();
    try{
        json.put("type", STATE_LIST_LOADED);
        json.put("status", statusCode);
        switch (statusCode) {
            case AppStateClient.STATUS_OK:
                JSONArray jsonStates = new JSONArray();
                json.put("states", jsonStates);
                AppState state;
                JSONObject jsonState;
                for(int i=0,l=buffer.getCount();i<l;i++){
                    state = buffer.get(i);
                    jsonState = new JSONObject();
                    if (state.hasConflict()){
                        jsonState.put("type", STATE_CONFLICTED);
                        jsonState.put("stateKey", state.getKey());
                        jsonState.put("version", state.getConflictVersion());
                        jsonState.put("localVersion", state.getLocalVersion());
                        jsonState.put("localData", new JSONObject(new String(state.getLocalData())));
                        jsonState.put("serverData", new JSONObject(new String(state.getConflictData())));
                    }else{
                        jsonState.put("type", STATE_LOADED);
                        jsonState.put("status", statusCode);
                        jsonState.put("stateKey", state.getKey());
                        jsonState.put("data", new JSONObject(new String(state.getLocalData())));
                    }
                    jsonStates.put(jsonState);
                }
                // Data was successfully loaded from the cloud: merge with local data.
                break;        
            case AppStateClient.STATUS_NETWORK_ERROR_NO_DATA:
                // can't reach cloud, and we have no local state. Warn user that
                // they may not see their existing progress, but any new progress won't be lost.
                break;
            case AppStateClient.STATUS_NETWORK_ERROR_STALE_DATA:
                // can't reach cloud, but we have locally cached data.
                break;
            case AppStateClient.STATUS_CLIENT_RECONNECT_REQUIRED:
                // need to reconnect AppStateClient
                mHelper.reconnectClients(clientTypes);
                break;
            case AppStateClient.STATUS_INTERNAL_ERROR:
                // if an unexpected error occurred in the service.
                break;
            default:
                // error
                break;
        }
    }catch(JSONException ex){
        Log.e(TAG, "STATE_LIST_LOADED ["+statusCode+"]["+buffer.getCount()+"] exception: "+ex.getMessage());
        return;
    }
    buffer.close();

    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, json);
    pluginResult.setKeepCallback(true);
    connectionCB.sendPluginResult(pluginResult);
}
 
开发者ID:ldarren,项目名称:pico-phonegap-base,代码行数:61,代码来源:PlayServices.java

示例10: getAppStateClient

import com.google.android.gms.appstate.AppStateClient; //导入依赖的package包/类
protected AppStateClient getAppStateClient() {
	return mHelper.getAppStateClient();
}
 
开发者ID:kyokomi,项目名称:NativeBaseGameUtils,代码行数:4,代码来源:BaseGameNativeActivity.java


注:本文中的com.google.android.gms.appstate.AppStateClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。