0

这是日志:

08-28 13:50:47.648: A/libc(1010): @@@ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x2a26bc90
08-28 13:50:47.648: A/libc(1010): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 1020 (FinalizerDaemon)
08-28 13:50:48.698: W/ActivityManager(149): Scheduling restart of crashed service com.android.KnowingLife/.PushNotification.NotificationService in 5000ms
08-28 13:50:48.698: W/ActivityManager(149): Force removing ActivityRecord{412a2c70 com.android.KnowingLife/.PhoneSynActivity}: app died, no saved state
08-28 13:50:48.807: W/GpsLocationProvider(149): Unneeded remove listener for uid 1000
08-28 13:50:49.257: E/Trace(1064): error opening trace file: No such file or directory (2)
08-28 13:50:50.017: W/GpsLocationProvider(149): Duplicate add listener for uid 10044
08-28 13:50:52.827: W/InputMethodManagerService(149): Got RemoteException sending setActive(false) notification to pid 1010 uid 10044

我在我的模拟器(4.1版)中运行它,我正在向本地批量插入联系人。它通常工作得很好,但是我有600多个联系人要插入到本地,当插入到大约6%时它不起作用。我不不知道怎么给你看,这是我的代码,看看这个,你会发现问题,谢谢

/**
 * insert 
 */
class InsertContactsTask extends AsyncTask<Void, Integer, Integer> {
    String detail;

    public InsertContactsTask(String detail) {
        this.detail = detail;
    }

    @SuppressWarnings("deprecation")
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        showDialog(PROGRESS_DIALOG);
    }

    @Override
    protected Integer doInBackground(Void... params) {
        String[] itemRecord = detail.split(ParseData.getInstance()
                .getRecordSplitFalg(), -1);
        int count = itemRecord.length;
        wait_Dialog.setMax(count);
        ArrayList<ContentProviderOperation> contentOper = null;
        contentOper = new ArrayList<ContentProviderOperation>();

        for (int i = 0; i < itemRecord.length; i++) {
            int rawContactInsertIndex = contentOper.size();
            String[] item = null;
            try {
                item = itemRecord[i].split(ParseData.getInstance()
                        .getFiledSplitFlag(), -1);
                contentOper.add(ContentProviderOperation
                        .newInsert(RawContacts.CONTENT_URI)
                        .withValue(RawContacts.ACCOUNT_TYPE, null)
                        .withValue(RawContacts.ACCOUNT_NAME, null).build());

                contentOper.add(ContentProviderOperation
                        .newInsert(ContactsContract.Data.CONTENT_URI)
                        .withValueBackReference(Data.RAW_CONTACT_ID,
                                rawContactInsertIndex)
                        .withValue(Data.MIMETYPE,
                                StructuredName.CONTENT_ITEM_TYPE)
                        .withValue(StructuredName.DISPLAY_NAME, item[0])
                        .build());

                for (int j = 1; j < item.length; j++) {
                    if (item[j].startsWith("1")) {
                        String phoneType = item[j].substring(1, 2);
                        int iType;
                        String label = null;
                        if (phoneType.compareToIgnoreCase("a") >= 0)
                            iType = phoneType.compareToIgnoreCase("a") + 10;
                        else
                            iType = Integer.parseInt(phoneType);
                        if (iType == 0)
                            label = item[j + 1];
                        contentOper
                                .add(ContentProviderOperation
                                        .newInsert(
                                                android.provider.ContactsContract.Data.CONTENT_URI)
                                        .withValueBackReference(
                                                Data.RAW_CONTACT_ID,
                                                rawContactInsertIndex)
                                        .withValue(Data.MIMETYPE,
                                                Phone.CONTENT_ITEM_TYPE)
                                        .withValue(Phone.NUMBER,
                                                item[j].substring(2))
                                        // "data1"
                                        .withValue(Phone.TYPE, iType)
                                        .withValue(Phone.LABEL, label)
                                        .build());
                        if (iType == 0)
                            j++;
                    } else {
                        String emailType = item[j].substring(1, 2);
                        int iEmailType = Integer.parseInt(emailType);
                        String emailLabel = null;
                        if (iEmailType == 0)
                            emailLabel = item[j + 1];
                        contentOper
                                .add(ContentProviderOperation
                                        .newInsert(
                                                android.provider.ContactsContract.Data.CONTENT_URI)
                                        .withValueBackReference(
                                                Data.RAW_CONTACT_ID,
                                                rawContactInsertIndex)
                                        .withValue(Data.MIMETYPE,
                                                Email.CONTENT_ITEM_TYPE)
                                        .withValue(Email.DATA,
                                                item[j].substring(2))
                                        .withValue(Email.TYPE, iEmailType)
                                        .withValue(Email.LABEL, emailLabel)
                                        .build());
                        if (iEmailType == 0)
                            j++;
                    }
                }
                int iUpdate = i + 1;
                if (iUpdate % 20 == 0 || iUpdate == itemRecord.length) {
                    try {
                        @SuppressWarnings("unused")
                        ContentProviderResult[] results = PhoneSynActivity.this
                                .getContentResolver().applyBatch(
                                        ContactsContract.AUTHORITY,
                                        contentOper);
                        contentOper.clear();
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    } catch (OperationApplicationException e) {
                        e.printStackTrace();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                    publishProgress(i);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        return count;
    }

    @Override
    protected void onProgressUpdate(Integer... values) {
        super.onProgressUpdate(values);
        wait_Dialog.setProgress(values[0]);
    }

    @Override
    protected void onPostExecute(Integer count) {
        super.onPostExecute(count);
        wait_Dialog.dismiss();
        txt_count.setText( count+ "");
        Toast.makeText(PhoneSynActivity.this,
                R.string.string_download_suc, Toast.LENGTH_LONG).show();
    }
}
4

0 回答 0