Android 强制新的解析安装
正如我先前在这个问题中所问的: 我想在用户注销应用程序时删除/清除android手机上的parse安装。我可以通过一个脚本从web上删除parse安装,然后我必须从手机的ram/磁盘上清除它Android 强制新的解析安装,android,parse-platform,Android,Parse Platform,正如我先前在这个问题中所问的: 我想在用户注销应用程序时删除/清除android手机上的parse安装。我可以通过一个脚本从web上删除parse安装,然后我必须从手机的ram/磁盘上清除它 我的问题是,在我这样做之后,如何强制解析库触发创建新的解析安装 我已经能够使用android parse sdk 1.13.1成功删除“本地”parse安装缓存 ParseInstallation installation = ParseInstallation.getCurrentInstallation
我的问题是,在我这样做之后,如何强制解析库触发创建新的解析安装 我已经能够使用android parse sdk 1.13.1成功删除“本地”parse安装缓存
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
Class clazz = installation.getClass();
Method[] methods = clazz.getDeclaredMethods();
Method method1 = clazz.getDeclaredMethod("getCurrentInstallationController");
method1.setAccessible(true);
Object result = method1.invoke(installation);
Method method2 = result.getClass().getDeclaredMethod("clearFromDisk");
method2.setAccessible(true);
String result2=(String) method2.invoke(result);
Method method3 = result.getClass().getDeclaredMethod("clearFromMemory");
method3.setAccessible(true);
String result3=(String) method3.invoke(result);
每次我的应用程序启动时,我都会检查安装是否可以保存,如果不能保存,我只需重新创建另一个安装
这样,根据您的用例,可以安全地从parse server中删除安装。我的parse安装只保存对我的用户对象的引用,因此我可以查询和发送推送通知
final ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("user", ParseUser.getCurrentUser());
installation.saveInBackground()
.continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) throws Exception {
if (task.isFaulted()) {
try {
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
Class clazz = installation.getClass();
Method[] methods = clazz.getDeclaredMethods();
Method method1 = clazz.getDeclaredMethod("getCurrentInstallationController");
method1.setAccessible(true);
Object result = method1.invoke(installation);
Method method2 = result.getClass().getDeclaredMethod("clearFromDisk");
method2.setAccessible(true);
String result2=(String) method2.invoke(result);
Method method3 = result.getClass().getDeclaredMethod("clearFromMemory");
method3.setAccessible(true);
String result3=(String) method3.invoke(result);
} catch (Exception ex) {
ex.printStackTrace();
}
}
return null;
}
})
final ParseInstallation=ParseInstallation.getCurrentInstallation();
installation.put(“user”,ParseUser.getCurrentUser());
安装。saveInBackground()
.continueWithTask(新的continueWithTask(){
@凌驾
然后公共任务(任务任务)引发异常{
if(task.isFaulted()){
试一试{
ParseInstallation=ParseInstallation.getCurrentInstallation();
Class clazz=installation.getClass();
方法[]methods=clazz.getDeclaredMethods();
方法method1=clazz.getDeclaredMethod(“getCurrentInstallationController”);
方法1.setAccessible(true);
对象结果=method1.invoke(安装);
方法method2=result.getClass().getDeclaredMethod(“clearFromDisk”);
方法2.setAccessible(true);
字符串result2=(字符串)方法2.invoke(结果);
方法method3=result.getClass().getDeclaredMethod(“clearFromMemory”);
方法3.setAccessible(true);
字符串result3=(字符串)方法3.invoke(结果);
}捕获(例外情况除外){
例如printStackTrace();
}
}
返回null;
}
})
希望这有点道理…这不是应用程序状态的准确表示。只要未卸载应用程序,设备上就存在安装。如果从服务器上删除安装,那么服务器比客户端知道的要少,这在概念上可能不是您想要的。