难道是预期的应用力INSTANCEID变化何时休? [英] Is it expected that InstanceId change on app force stopped?

查看:326
本文介绍了难道是预期的应用力INSTANCEID变化何时休?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试播放服务GCM 7.5。然而,这看起来不错的实例id类。然而,该实例ID字符串改变我每次刷卡应用了近期任务时间,或强制停止应用程序。如果该活动是完成它不会改变()。它是预期的行为?应在实例ID是保持不变的,我们先得到它?

下面是codeS得到GCM令牌和实例ID:

 实例id =实例ID InstanceID.getInstance(本);
            字符串标记= instanceID.getToken(的getString(R.string.gcm_defaultSenderId),GoogleCloudMessaging.INSTANCE_ID_SCOPE);
            Log.e(FOO的getClass()getSimpleName()+:+ instanceID.getId()+|+令牌);
            sendPushRegistrationTokenToServer(标记);

下面是codeS以后要阅读实例ID:

 实例id =实例ID InstanceID.getInstance(本)
            tokenTextView.setText(instanceID.getId());


解决方案

要解决此问题的更新您的GCM,我可以证实,GCM 7.8工作正常。

I am trying out Play Services GCM 7.5. However, it looks nice to have InstanceID class. However, the instance ID string changes every time I swipe the app out of Recent tasks, or force stop the app. It doesn't change if the activity is finish(). Is it expected behavior? Shall the instance ID be persisted the first we get it?

Below is the codes to get GCM token and instance id:

            InstanceID instanceID = InstanceID.getInstance(this);
            String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE);
            Log.e("FOO", getClass().getSimpleName() + ": " + instanceID.getId() + " | " + token);
            sendPushRegistrationTokenToServer(token);

Below is the codes to read the instance ID later:

            InstanceID instanceID = InstanceID.getInstance(this)
            tokenTextView.setText(instanceID.getId());

解决方案

To fix this update your GCM, I can confirm that GCM 7.8 works fine.

这篇关于难道是预期的应用力INSTANCEID变化何时休?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆