Android 23 – 从备份中排除GCM注册ID

前端之家收集整理的这篇文章主要介绍了Android 23 – 从备份中排除GCM注册ID前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用Azure发送推送通知的应用程序. Azure依次使用GCM发送到 Android设备.

我注意到我的AndroidManifest.xml中有一个警告说明

On SDK version 23 and up,your app data will be automatically backed
up,and restored on app install. Your GCM regid will not work across
restores,so you must ensure that it is excluded from the back-up set.
Use the attribute android:fullBackupContent to specify an @xml
resource which configures which files to backup.

我按照https://developer.android.com/training/backup/autosyncapi.html?hl=in#configuring的说明进行操作

但是我对如何从备份中排除GCM regID感到难过?这是我目前的设置.

表现

<application
        android:allowBackup="true"
        android:fullBackupContent="@xml/backup_scheme"
        ........

RES / XML / backup_scheme.xml

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <exclude domain="sharedpref" path=""/>
</full-backup-content>

我把什么作为路径?我应该在某个地方放置一个物理文件吗?

UPDATE

所以我想我弄明白了.在我的RegistrationIntentService.java文件中,我将用户registrationID存储在字符串“registrationID”下的共享首选项中.所以我假设我使用以下内容……

<exclude domain="sharedpref" path="registrationID"/>

对?

解决方法

所以我明白了.在我的RegistrationIntentService.java文件中,我将用户registrationID存储在字符串“registrationID”下的共享首选项中.所以在backup_scheme.xml文件中使用以下内容……
<exclude domain="sharedpref" path="registrationID"/>
原文链接:https://www.f2er.com/android/316082.html

猜你在找的Android相关文章