android - 如何实现联系人连接(mimetype)来启动我的应用程序?

标签 android android-intent android-manifest mime-types android-contacts

我的应用程序在这种情况下需要一些帮助:当用户转到特定联系人并单击该链接图标(如 What's up )时,应用程序 (eq. WhatsUp) 将使用该联系人 ID 打开。

Here you can see the links icons

到目前为止我做了什么: - 我成功地为特定联系人添加了我的自定义数据。我有我的应用程序图标和该联系人的 mimedata 自定义数据。我在联系人数据中定义的 mimetype 是:"vnd.android.cursor.item/com.sunny.contacts.Account"

现在在 list 上我配置了以下主要 Activity :

    <activity
       android:name=".ActivityMain"
       android:label="@string/app_name"
       android:windowSoftInputMode="adjustResize|adjustPan">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />     
        </intent-filter>    
        <intent-filter>         
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/com.sunny.contacts.Account"/>      
        </intent-filter>    
   </activity>

ActivityMain::OnCreate 上,我正在读取 Intent 数据,但不幸的是应用程序没有打开,我不知道出了什么问题。

谢谢你的帮助,

最佳答案

而不是 <data android:mimeType="vnd.android.cursor.item/com.sunny.contacts.Account"/> 用这个<data android:mimeType="vnd.android.cursor.item/vnd.com.sunny.contacts.profile"/>

你在xml中定义的

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

关于android - 如何实现联系人连接(mimetype)来启动我的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28559119/

相关文章:

java - Android Studio - 使用 jsoup 解析抛出错误 (java.lang.NullPointerException)

java - 如何创建具有扩展另一个类并实现接口(interface)的类型参数的基本适配器?

android - 调用 DialogFragment

android - 使用 monkeyrunner : How can I call intents during the execution of an application?

android - 使用 Intent URL 启动 Android 浏览器的私有(private) Activity

android - Robolectric 找不到资源或 list 文件

java - 以编程方式从 android 中的 manifest.xml 中检索权限

android,如何重命名文件?

android - bundle 额外发送错误的字符串

java - Android: list 中无法识别 targetApi