我想为给定的联系人添加自定义语音。
我的代码是:
@Override
protected Void doInBackground(Void... params) {
for (PhoneContact phoneContact : this.phoneContactList) {
progressDialog.incrementProgressBy(1);
try {
ContentResolver contentResolver = ctx.getContentResolver();
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
operations.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, Integer.parseInt(phoneContact.getId()))
.withValue(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM)
.withValue(ContactsContract.CommonDataKinds.Phone.LABEL, "ABCDE")
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, PhoneNumberFormatter.formatNumber(ctx, "1232444444"))
.build());
contentResolver.applyBatch(ContactsContract.AUTHORITY, operations);
} catch (RemoteException e) {
e.printStackTrace();
} catch (OperationApplicationException e) {
e.printStackTrace();
}
}
progressDialog.dismiss();
return null;
}
但是,当我运行此代码时,没有任何东西可以依赖。 每个人都可以帮助我吗?
答案 0 :(得分:0)
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>