構築している連絡先プロバイダーで、連絡先グループを作成してから、そのグループに連絡先を追加します。これは、新しいグループが存在しない場合に作成するための私のコードです。
if (groupId == 0) {
// Sample group doesn't exist yet, so create it
final ContentValues contentValues = new ContentValues();
contentValues.put(Groups.ACCOUNT_NAME, account.name);
contentValues.put(Groups.ACCOUNT_TYPE, account.type);
contentValues.put(Groups.TITLE, Constants.GROUP_NAME);
contentValues.put(Groups.GROUP_IS_READ_ONLY, true);
final Uri newGroupUri = resolver.insert(Groups.CONTENT_URI, contentValues);
Log.d(TAG, newGroupUri.toString());
groupId = ContentUris.parseId(newGroupUri);
}
これをAndroid4.0または4.1で実行すると機能しますが、2.3で実行するnewGroupUri
とnullになります。2.3の問題は何ですか。エミュレータと電話の両方で試しました