Android MarshMallow 自动备份 - 我现在是否需要排除特定于设备的信息,例如 GCM id?

Android MarshMallow auto backup - do i need to exclude device specific Info like GCM id now?

这是关于 play service backup and restore for MarshMallow

的一些信息

如您所见,现在不需要 BackupAgentHelper。开发人员无需努力备份应用程序,只需在用户设置中切换即可将其关闭和打开。现在假设我有一个 GCM 注册 ID 已经存储在 sharedPreference 中,现在用户切换设备并进行自动备份。旧的 GCM id 将包含在恢复中,新设备将不会注册 GCM,因此没有资格接收远程通知。

所以就我而言,我是否必须编写一个备份方案 xml 文件来排除 gcm ID,如果是的话我该怎么做:通过排除 xml 我的意思是这个属性在清单的应用标签:android:fullBackupContent="@xml/mybackupscheme"

是的,我们需要排除 GCM id。 Android documentation 指出...

For apps that use Google Cloud Messaging (GCM) for push notifications, backing up the registration token that Google Cloud Messaging registration returned can cause unexpected behavior in notifications for the restored app. This is because when a user installs your app on a new device, the app must query the GCM API for a new registration token. If the old registration is present, because the system had backed it up and restored it, the app doesn't seek the new token. To prevent this issue from arising, exclude the registration token from the set of backed-up files.

排除方法详见here