我得到的聯繫人的名稱和電子郵件ID,它在HTC Desire中工作正常,但每當我嘗試在星系選項卡中運行代碼時,它顯示我memObj中沒有內存和空指針on ... while(emailCur.moveToNext())。內存問題/光標顯示空指針
這裏是我的代碼
private void getPeopleList() {
String name, email;
Runtime.getRuntime().maxMemory();
c = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
name = c.getString(c
.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String id = c.getString(c
.getColumnIndex(BaseColumns._ID));
cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = ?", new String[] { id }, null);
emailCur = cr.query(Email.CONTENT_URI, null,
Email.CONTACT_ID + " = " + id, null, null);
int j = 0;
while (emailCur.moveToNext()) {
bindData = new BindData[emailCur.getCount()];
bindData = new BindData();
email = emailCur
.getString(emailCur
.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
bindData.setEmailId(email);
bindData.setName(name);
Log.d("doubt : ", name+"//"+email);
mArrayList.add(bindData);
j++;
}
emailCur.close();
}
c.close();
}
}
我打電話使用的工作線程運行的這種方法。
如果需要任何信息,請告訴我。
這裏是我的日誌貓
06-29 16:13:26.854: ERROR/IMemory(6180): binder=0xdf3f68 transaction failed fd=-2147483647, size=0, err=-2147483646 (Unknown error: 2147483646)
06-29 16:13:26.854: ERROR/IMemory(6180): cannot dup fd=-2147483647, size=0, err=-2147483646 (Bad file number)
06-29 16:13:26.854: ERROR/IMemory(6180): cannot map BpMemoryHeap (binder=0xdf3f68), size=0, fd=-1 (Bad file number)
06-29 16:13:26.854: ERROR/JavaBinder(6180): *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
06-29 16:13:26.854: ERROR/JavaBinder(6180): java.lang.RuntimeException: No memory in memObj
06-29 16:13:26.854: ERROR/JavaBinder(6180): at android.database.CursorWindow.native_init(Native Method)
06-29 16:13:26.854: ERROR/JavaBinder(6180): at android.database.CursorWindow.<init>(CursorWindow.java:518)
06-29 16:13:26.854: ERROR/JavaBinder(6180): at android.database.CursorWindow.<init>(CursorWindow.java:27)
06-29 16:13:26.854: ERROR/JavaBinder(6180): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:493)
06-29 16:13:26.854: ERROR/JavaBinder(6180): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:496)
06-29 16:13:26.854: ERROR/JavaBinder(6180): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:103)
06-29 16:13:26.854: ERROR/JavaBinder(6180): at android.os.Binder.execTransact(Binder.java:288)
06-29 16:13:26.854: ERROR/JavaBinder(6180): at dalvik.system.NativeStart.run(Native Method)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): FATAL EXCEPTION: main
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): java.lang.NullPointerException
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at com.meomyo.fanaticfaninit.utils.MyCustomList.getPeopleList(MyCustomList.java:172)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at com.meomyo.fanaticfaninit.utils.MyCustomList.access$0(MyCustomList.java:144)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at com.meomyo.fanaticfaninit.utils.MyCustomList$1.run(MyCustomList.java:121)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at android.os.Handler.handleCallback(Handler.java:587)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at android.os.Handler.dispatchMessage(Handler.java:92)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at android.os.Looper.loop(Looper.java:123)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at java.lang.reflect.Method.invokeNative(Native Method)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at java.lang.reflect.Method.invoke(Method.java:521)
06-29 16:13:26.858: ERROR/AndroidRuntime(6388): at
哪條線撞上了? – nickfox
@Nic:while(emailCur.moveToNext())。 – PiyushMishra