我有两个类:用户和以下我想加入他们,所以我这样做了:
@Override
protected Void doInBackground(Void... params) {
users = new ArrayList<UserInfo>();
try {
ParseQuery<ParseObject> innerQuery = new ParseQuery<ParseObject>("following");
innerQuery.whereEqualTo("username", "sara");
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.whereMatchesKeyInQuery("username", "follower_username", innerQuery);
query.orderByAscending("createdAt");
ob = query.find();
for (ParseObject user : ob) {
ParseFile image = (ParseFile) user.get("pic");
UserInfo map = new UserInfo();
map.setUserName((String) user.get("username"));
map.setPic(image.getUrl());
users.add(map);
}
} catch (ParseException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
return null;
}
这里是Logcat:
04-16 10:49:17.586: W/dalvikvm(23216): threadid=11: thread exiting with uncaught exception (group=0x417d9898)
04-16 10:49:17.586: E/AndroidRuntime(23216): FATAL EXCEPTION: AsyncTask #1
04-16 10:49:17.586: E/AndroidRuntime(23216): java.lang.RuntimeException: An error occured while executing doInBackground()
04-16 10:49:17.586: E/AndroidRuntime(23216): at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-16 10:49:17.586: E/AndroidRuntime(23216): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
04-16 10:49:17.586: E/AndroidRuntime(23216): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
04-16 10:49:17.586: E/AndroidRuntime(23216): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
04-16 10:49:17.586: E/AndroidRuntime(23216): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-16 10:49:17.586: E/AndroidRuntime(23216): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-16 10:49:17.586: E/AndroidRuntime(23216): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-16 10:49:17.586: E/AndroidRuntime(23216): at java.lang.Thread.run(Thread.java:841)
04-16 10:49:17.586: E/AndroidRuntime(23216): Caused by: java.lang.NullPointerException
04-16 10:49:17.586: E/AndroidRuntime(23216): at com.androidbegin.parselistviewimgtxt.MainActivity$RemoteDataTask.doInBackground(MainActivity.java:75)
04-16 10:49:17.586: E/AndroidRuntime(23216): at com.androidbegin.parselistviewimgtxt.MainActivity$RemoteDataTask.doInBackground(MainActivity.java:1)
04-16 10:49:17.586: E/AndroidRuntime(23216): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-16 10:49:17.586: E/AndroidRuntime(23216): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-16 10:49:17.586: E/AndroidRuntime(23216): ... 4 more
04-16 10:49:17.996: D/AbsListView(23216): onDetachedFromWindow
04-16 10:49:17.996: D/AbsListView(23216): unregisterIRListener() is called
04-16 10:49:18.026: E/WindowManager(23216): Activity com.androidbegin.parselistviewimgtxt.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42c02818 V.E..... R......D 0,0-1026,288} that was originally added here
04-16 10:49:18.026: E/WindowManager(23216): android.view.WindowLeaked: Activity com.androidbegin.parselistviewimgtxt.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42c02818 V.E..... R......D 0,0-1026,288} that was originally added here
04-16 10:49:18.026: E/WindowManager(23216): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:449)
04-16 10:49:18.026: E/WindowManager(23216): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:258)
04-16 10:49:18.026: E/WindowManager(23216): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:73)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.Dialog.show(Dialog.java:285)
04-16 10:49:18.026: E/WindowManager(23216): at com.androidbegin.parselistviewimgtxt.MainActivity$RemoteDataTask.onPreExecute(MainActivity.java:54)
04-16 10:49:18.026: E/WindowManager(23216): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
04-16 10:49:18.026: E/WindowManager(23216): at android.os.AsyncTask.execute(AsyncTask.java:534)
04-16 10:49:18.026: E/WindowManager(23216): at com.androidbegin.parselistviewimgtxt.MainActivity.onCreate(MainActivity.java:37)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.Activity.performCreate(Activity.java:5369)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.ActivityThread.access$700(ActivityThread.java:165)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
04-16 10:49:18.026: E/WindowManager(23216): at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 10:49:18.026: E/WindowManager(23216): at android.os.Looper.loop(Looper.java:137)
04-16 10:49:18.026: E/WindowManager(23216): at android.app.ActivityThread.main(ActivityThread.java:5450)
04-16 10:49:18.026: E/WindowManager(23216): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 10:49:18.026: E/WindowManager(23216): at java.lang.reflect.Method.invoke(Method.java:525)
04-16 10:49:18.026: E/WindowManager(23216): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
04-16 10:49:18.026: E/WindowManager(23216): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
04-16 10:49:18.026: E/WindowManager(23216): at dalvik.system.NativeStart.main(Native Method)
如果用户有一个关注者但是如果很多,那么应用程序崩溃为什么? 除了User类之外,它运行良好