本文介绍了具有NullPointerException的ParseObject.pinAllInBackground()结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个扩展了ParseObject
类的News
对象.我希望将其缓存在本地,以便以后可以从本地存储中获取.
I have a News
objects that extends ParseObject
class. I'd like it to be cached locally so that I can fetch it from local store later.
这是我的回调,其中包括对.pinAllInBackground(..)
方法的调用:
Here is my callback that includes call to .pinAllInBackground(..)
method:
FindCallback<News> onNewsReceived = new FindCallback<News>() {
@Override
public void done(List<News> arg0, ParseException arg1) {
if (arg1 == null) {
newsList = new ArrayList<News>(arg0);
ParseObject.pinAllInBackground(newsList);
initializeList();
} else {
Log.d("TAG1", String.valueOf(arg1.getMessage()));
}
}
};
运行此命令时,出现以下异常:
When i run this I get the following exception:
09-22 11:31:25.637: E/AndroidRuntime(27380): FATAL EXCEPTION: main
09-22 11:31:25.637: E/AndroidRuntime(27380): Process: pl.holdapp.osw, PID: 27380
09-22 11:31:25.637: E/AndroidRuntime(27380): java.lang.NullPointerException
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParsePin.getParsePin(ParsePin.java:19)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParsePin.pinAllObjectsAsync(ParsePin.java:44)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParseObject.pinAllAsync(ParseObject.java:3320)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParseObject.pinAllInBackground(ParseObject.java:3417)
09-22 11:31:25.637: E/AndroidRuntime(27380): at pl.holdapp.osw.fragments.NewsFragment$2.done(NewsFragment.java:68)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.FindCallback.internalDone(FindCallback.java:45)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.FindCallback.internalDone(FindCallback.java:31)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.Parse$6$1.run(Parse.java:917)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.os.Handler.handleCallback(Handler.java:733)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.os.Handler.dispatchMessage(Handler.java:95)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.os.Looper.loop(Looper.java:157)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.app.ActivityThread.main(ActivityThread.java:5356)
09-22 11:31:25.637: E/AndroidRuntime(27380): at java.lang.reflect.Method.invokeNative(Native Method)
09-22 11:31:25.637: E/AndroidRuntime(27380): at java.lang.reflect.Method.invoke(Method.java:515)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
09-22 11:31:25.637: E/AndroidRuntime(27380): at dalvik.system.NativeStart.main(Native Method)
arg0
不为null,因此我完全不知道它来自何处.
arg0
is not null and therefore I completely don't understand where that comes from.
推荐答案
显然,我在固定之前没有呼叫Parse.enableLocalDatastore(context);
.
Apparently I didn't call Parse.enableLocalDatastore(context);
before pinning.
这篇关于具有NullPointerException的ParseObject.pinAllInBackground()结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!