打开要编辑的同步适配器接触的活动 [英] open an activity to edit contact in sync adapter

查看:140
本文介绍了打开要编辑的同步适配器接触的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的SampleSyncAdapter有下面这段code:

In the Android SampleSyncAdapter there is the following piece of code:

/**
 * Adds a profile action
 *
 * @param userId the userId of the sample SyncAdapter user object
 * @return instance of ContactOperations
 */
public ContactOperations addProfileAction(long userId) {
    mValues.clear();
    if (userId != 0) {
        mValues.put(SampleSyncAdapterColumns.DATA_PID, userId);
        mValues.put(SampleSyncAdapterColumns.DATA_SUMMARY, mContext
            .getString(R.string.syncadapter_profile_action));
        mValues.put(SampleSyncAdapterColumns.DATA_DETAIL, mContext
            .getString(R.string.view_profile));
        mValues.put(Data.MIMETYPE, SampleSyncAdapterColumns.MIME_PROFILE);
        addInsertOp();
    }
    return this;
}

我说这是过滤器,我的活动

I added this as filter for my activity

    <intent-filter>
        <action android:name="@string/syncadapter_profile_action" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="vnd.android.cursor.item/vnd.myapp.profile"
            android:host="contacts" />
     </intent-filter>  

在这里SampleSyncAdapterColumns.MIME_PROFILE = vnd.android.cursor.item / vnd.myapp.profile

where SampleSyncAdapterColumns.MIME_PROFILE = vnd.android.cursor.item/vnd.myapp.profile

我增加了一个触点,我可以看到该条目,但是当我点击它没有任何反应。我应该怎么做才能开始活动,当用户点击就可以了? 我试图做的建议这里为pre-蜂窝设备:关键是要插入数据行,编辑在MyApp的,这将用户带到您的应用程序和您的应用程序 然后将提供一个编辑器的活动

I added a contact and I can see the entry but when I click on it nothing happens. What should I do to start an activity when the user clicks on it? I was trying to do what is suggested Here for Pre-honeycomb devices: The trick is to insert a data row, "Edit in MyApp", which would take the user to your app and your app would then provide an editor activity

推荐答案

我觉得你的意图过滤器可能不正确。据<一href="http://stackoverflow.com/questions/5490105/perform-some-action-with-custom-field-of-contact">this进入,正确的操作和数据项应该是这样的:

I think your intent filter might be incorrect. According to this entry, the correct action and data items should be something like the following:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.item/vnd.myapp.profile" />
</intent-filter>

这篇关于打开要编辑的同步适配器接触的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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