[英]Use Android Contacts app to edit a raw contact which was added by a custom ContentProvider
我的应用使用自定义ContentProvider
将联系人“ Bob ”添加到地址簿中。 在Android通讯录应用中, Bob与任何其他(Google)联系人一样显示。 但是当我在联系人应用程序中编辑Bob时,我的应用程序提供的数据是不可编辑的。 到现在为止还挺好。
我的问题是 :在我的应用程序中,是否有办法启动联系人应用程序,允许用户编辑属于我的应用程序的Bob部分?
我试图使用相应的Intent
,如本Android指南中所述 ,但使用原始联系人uri为Bob :
Uri rawUri = getRawContactUri("Bob");
Intent intent = new Intent(Intent.ACTION_EDIT, rawUri);
startActivityForResult(intent, EDIT_CONTACT_RESULT);
它会显示联系人应用程序,但仍无法编辑Bob的数据。
关于在选择自定义字段时如何从联系人应用程序中打开应用程序或如何正确触发ACTION_EDIT
,有很多关于SO的问题。
但我没有找到任何声明 - 包括引用 - 如果可以使用Contacts应用程序让用户编辑自定义原始联系人。 有没有人有线索,最好是参考?
您需要将EditSchema添加到您的contact.xml文件并添加元数据,指向清单文件的SyncService部分中的该文件,如下所示:
<service
android:name=".syncadapter.SyncService"
android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
<meta-data
android:name="android.provider.CONTACTS_STRUCTURE"
android:resource="@xml/contacts" />
</service>
以下是官方来源的EditSchema示例: http ://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.2.2_r1/packages/apps/Contacts/tests /res/xml/test_basic_contacts.xml/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.