Custom fields on new contact

穿精又带淫゛_ 提交于 2019-11-28 05:11:52

问题


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



来源:https://stackoverflow.com/questions/7529056/custom-fields-on-new-contact

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!