1

内部 Contact アクティビティを使用して、新しい Contact を作成したいと考えています。コードは次のとおりです。

        Intent i = new Intent();
    i.setAction(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setData(Uri.fromParts("tel", "12345678", null));
    i.putExtra(ContactsContract.Intents.EXTRA_FORCE_CREATE, true);
    i.putExtra(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_WORK); 
    i.putExtra(ContactsContract.Intents.Insert.EMAIL, "naoknaoknaok@gmail.com");
    i.putExtra(ContactsContract.CommonDataKinds.Email.TYPE, ContactsContract.CommonDataKinds.Email.TYPE_WORK);
    i.putExtra(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, "Ide");
    i.putExtra(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, "Vele");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.COMPANY, "Company name");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.TYPE, ContactsContract.CommonDataKinds.Organization.TYPE_WORK);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.LABEL, "label");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.TITLE, "job title");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.DEPARTMENT, "department");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.JOB_DESCRIPTION, "job description");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.SYMBOL, "symbol");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.OFFICE_LOCATION, "office location");

しかし、このコードは部分的にしか機能しません。アクティビティには電話番号とメール アドレスのみが表示され、他のフィールドは設定されていません。

エミュレータのスクリーンショットは次のとおりです: edit_contact1

含めなくて申し訳ありませんが、画像を含めるのに十分な評判がありません.

どんな助けでも大歓迎です!

いくつかの更新: 次のコードは、「指定された名前」フィールドを設定します。

i.putExtra(ContactsContract.Intents.Insert.NAME, "simple name");
4

1 に答える 1

1

ContactsContract.Intents.Insert.* の定数キーのみがインテント レシーバーによって理解されると思います。それは理にかなっています。

于 2011-01-04T23:22:22.487 に答える