简体   繁体   English

联系人的某些自定义字段无法在android4.0上运行

[英]Some custom filed of contact can not work on android4.0

I add an account to account&sync,the xml of ContactsSource is below, it can work normal on android2.3,but on android4.0.3,the "android:icon" and "android:summaryColumn" fields can not work.On contact detail page of addressbook,the connections section shows the icon of the account,not "@drawable/icon_bb" and the summaryColumn shows the account name,not "data2" in xml. 我将一个帐户添加到account&sync,ContactsSource的xml在下面,它可以在android2.3上正常工作,但是在android4.0.3上,“ android:icon”和“ android:summaryColumn”字段无法正常工作。在联系人详细信息页面上在地址簿中,“连接”部分显示帐户图标,而不是“ @ drawable / icon_bb”,summaryColumn显示帐户名称,而不是xml中的“ data2”。

<ContactsDataKind
    android:mimeType="vnd.android.cursor.item/vnd.com.android.bb.profile"
    android:icon="@drawable/icon_bb"
    android:summaryColumn="data2"
    android:detailColumn="data3"
    android:detailSocialSummary="true" />

Two tweaks here: 这里有两个调整:

1st you have to switch detailColumn with summaryColumn for Ice Cream Sandwitch. 首先,您必须将Ice Cream Sandwitch的detailColumnsummaryColumn切换。 Just put another contacts.xml into res/xml-v14 folder 只需将另一个contacts.xml放入res / xml-v14文件夹中

<ContactsDataKind
 ...
 android:summaryColumn="data3"
 android:detailColumn="data2"
 ... />

2nd to make icon work you have to set icon for intent-filter at AndroidManifest.xml 第二使图标工作,您必须在AndroidManifest.xml为Intent-filter设置图标

<intent-filter android:icon="@drawable/icon_bb" >
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.item/vnd.com.android.bb.profile"/>
</intent-filter>

First you need to add the <ContactsAccountType> to the following: viewStreamItemActivity="com.test.Activity" (this is the full path of your activity that will receive the intent when users click on the line item). 首先,您需要将<ContactsAccountType>添加到以下内容: viewStreamItemActivity="com.test.Activity" (这是您的活动的完整路径,当用户单击订单项时,它将收到该意图。) Sample: 样品:

<ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android" viewStreamItemActivity="com.test.Activity">

  <ContactsDataKind android:mimeType="vnd.android.cursor.item/vnd.com.android.bb.profile" android:icon="@drawable/icon_bb" android:summaryColumn="data2" android:detailColumn="data3" android:detailSocialSummary="true" />

</ContactsAccountType>

Once you have this you need to add in the manifest an intent filter for the icon inside the activity (com.test.Activity). 完成此操作后,您需要在清单中为活动(com.test.Activity)中的图标添加一个意图过滤器。 Sample: 样品:

<activity android:name=".Activity" android:label="@string/title_activity_main">
  <intent-filter android:icon="@drawable/icon_bb">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.item/vnd.com.android.bb.profile" />
  </intent-filter>
</activity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM