与联系人自定义字段执行一些动作 [英] Perform some action with custom field of Contact

查看:111
本文介绍了与联系人自定义字段执行一些动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的联系人添加自定义字段。它包括:

I have added custom field for my Contacts. It consists of:

<ContactsSource xmlns:android="http://schemas.android.com/apk/res/android">
 <ContactsDataKind
  android:icon="@drawable/ic_launcher"
  android:mimeType="vnd.android.cursor.item/vnd.com.mob.my_new.profile"
  android:summaryColumn="data2"
  android:detailColumn="data3"
  android:detailSocialSummary="true" />

现在。我想执行一些动作(例如 - 发起一个活动),当用户在Android的针数选择该我的领域。我如何实现这一点? (这将是类似于Facebook的自定义字段 - 显示个人资料页)

for now. I want to perform some action (for example - launch an activity) when user selects this my field in Android Contacs. How I can implement this? (It will be similar to facebook custom field - showing profile page)

推荐答案

我找到了答案。我们可以实现这样的功能: 1)建立新型隐形眼镜领域(见在回答最后链接);

I found the answer. We can implement such functionality by: 1) creating new type of Contacts field (see link at the end of answer);

2)创建活动,将执行此操作:

2) creating an Activity, which will perform this action:

if (getIntent().getData() != null) {
        Cursor cursor = managedQuery(getIntent().getData(), null, null, null, null);
        if (cursor.moveToNext()) {
            String username = cursor.getString(cursor.getColumnIndex("DATA1"));
            TextView tv = (TextView) findViewById(R.id.profiletext);
            tv.setText("This is the profile for " + username);
        }
    } else {
        // How did we get here without data?
        finish();
    }

3)添加特殊意图的活动在我们的Manifest.xml:

3) adding special intent to Activity in our Manifest.xml:

<activity android:name=".ProfileActivity"
                android:label="Profile">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/vnd.org.c99.SyncProviderDemo.profile" />
        </intent-filter>
    </activity>

答案(和全教程)被发现的这里

这篇关于与联系人自定义字段执行一些动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆