I'm experiencing a similar issue.
The contact is inserted without an issue, but on JB (only on JB) it has a 
button stating "Add to My Contacts".
Pressing that button causes a crash in the native contact fragment:

09-06 15:45:01.402   307   626 I ActivityManager: Start proc 
com.android.contacts for activity 
com.android.contacts/.activities.ContactDetailActivity: pid=10329 uid=10001 
gids={3003, 1015, 1028}
09-06 15:45:05.011 10329 10329 E AndroidRuntime: FATAL EXCEPTION: main
09-06 15:45:05.011 10329 10329 E AndroidRuntime: 
java.lang.NullPointerException
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
com.android.contacts.model.EntityModifier.getBestValidType(EntityModifier.java:303)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
com.android.contacts.model.EntityModifier.insertChild(EntityModifier.java:346)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
com.android.contacts.detail.ContactDetailFragment$AddToMyContactsQuickFix.execute(ContactDetailFragment.java:2063)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
com.android.contacts.detail.ContactDetailFragment$3.onClick(ContactDetailFragment.java:313)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
android.view.View.performClick(View.java:4084)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
android.view.View$PerformClick.run(View.java:16966)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
android.os.Handler.handleCallback(Handler.java:615)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
android.os.Handler.dispatchMessage(Handler.java:92)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
android.os.Looper.loop(Looper.java:137)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
android.app.ActivityThread.main(ActivityThread.java:4745)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
java.lang.reflect.Method.invokeNative(Native Method)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
java.lang.reflect.Method.invoke(Method.java:511)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-06 15:45:05.011 10329 10329 E AndroidRuntime: at 
dalvik.system.NativeStart.main(Native Method)
09-06 15:45:05.019   307   482 W ActivityManager:   Force finishing 
activity com.android.contacts/.activities.ContactDetailActivity

Anyone know how to get around it?

On Wednesday, September 12, 2012 4:45:51 PM UTC+3, akash wrote:
>
> Hi, 
> I am Adding Some Contacts to Native Android Phone Book, After executing 
> below code i am able to see the person in my android phone book, but when i 
> open the contact card of the person i inserted, contact card crashes. 
> Below is my code.
>
>  public static void insertAndroidContact(Context context, String name, 
> String Phone, String email)
>     {
>         ArrayList <ContentProviderOperation> ops = new 
> ArrayList<ContentProviderOperation>();
>         
>         ContentProviderOperation.Builder op =
>                 
> ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
>                 .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, 
> "Custom")
>                 .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, 
> name);
>         ops.add(op.build());
>
>      // Creates the display name for the new raw contact, as a 
> StructuredName data row.
>         op =
>                 
> ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
>                 
> .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
>                 .withValue(ContactsContract.Data.MIMETYPE,
>                         
> ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
>                 
> .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, 
> name);
>
>         // Builds the operation and adds it to the array of operations
>         ops.add(op.build());
>
>         op =
>                 
> ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
>                 
> .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
>                 .withValue(ContactsContract.Data.MIMETYPE,
>                         
> ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
>                 .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, 
> Phone)
>                 .withValue(ContactsContract.CommonDataKinds.Phone.TYPE, 
> "Mobile");
>
>         // Builds the operation and adds it to the array of operations
>         ops.add(op.build());
>
>         // Inserts the specified email and type as a Phone data row
>         op =
>                 
> ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
>                 
> .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
>                 .withValue(ContactsContract.Data.MIMETYPE,
>                         
> ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)
>                 .withValue(ContactsContract.CommonDataKinds.Email.ADDRESS, 
> email)
>                 .withValue(ContactsContract.CommonDataKinds.Email.TYPE, 
> "com.example");
>
>         /*
>          * Demonstrates a yield point. At the end of this insert, the 
> batch operation's thread
>          * will yield priority to other threads. Use after every set of 
> operations that affect a
>          * single contact, to avoid degrading performance.
>          */
>         op.withYieldAllowed(true);
>
>         // Builds the operation and adds it to the array of operations
>         ops.add(op.build());
>         
>         try {
>             
> context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
>         } 
>         catch (Exception e) {
>
>             // Display a warning
>             //Context ctx = getApplicationContext();
>             
>             CharSequence txt = "Contact Creation Failure";
>             int duration = Toast.LENGTH_SHORT;
>             Toast toast = Toast.makeText(context, txt, duration);
>             toast.show();
>
>         }
>     }
>
> Thank you
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to