Custom fields on new contact

2020-02-12 13:38发布

问题:

This is the 'add new contact' window. Is it possible to create custom data fields in this window?

My current custom fields are only visible on the 'contact details' window.

回答1:

It is possible to launch a new Add New Contact activity when the user clicks on the add new contact button. For that you will have to create your own activity and setContentView(R.layout.YOUR_CUSTOM_ACTIVITY_SCREEN). Now the next step is important. Add the following lines to the ManifestFile of your application:

<activity android:name=".YOUR_CUSTOM_ACTIVITY" >
        <intent-filter>
            <action android:name="android.intent.action.INSERT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.dir/contact"/>
        </intent-filter>
    </activity>

Now when the user click to add a new contact he will be shown 2 options. One will be your application and other would be the default activity to add contact.

Hope this answer helps.



回答2:

It seems like the only way to do it, is to catch the intent and show you're own edit contact activity( at least with android 2.1 and 2.3 ). I tries all day long to make a workable BroadcastReceiver working. but I never succed.

source : https://groups.google.com/forum/?fromgroups#!topic/android-developers/bKpXE1kn4kI and Custom accountType "edit contact" and "add contact" shows only name