Search code examples
androidandroid-intentandroid-contactsandroid-facebookfacebook-messenger

Android facebook messenger raw contact intent


Well, i'm getting RawContacts for a contact from ContactProvider. Viber, Whatsapp, Skype, Telegram, etc are launching well with

Uri uri = Uri.parse("content://com.android.contacts/data/" + rawContactId);
Intent i = new Intent(Intent.ACTION_VIEW, uri); 

But when it comes to Facebook Messenger's RawContacts something goes wrong

E/msgr(:):AbstractIntentHandlerActivity: Future failed for intent Intent { act=android.intent.action.VIEW dat=content://com.android.contacts/data/21839 flg=0x10800000 cmp=com.facebook.orca/com.facebook.messenger.intents.IntentHandlerActivity }. Waiting for result: false.

Does anybody know why standard contact-view Intent doesn't work well and is there elegant solution for this situation?

Standard Android Contacts application handles this situation well.


Solution

  • According to standard Android Contacts application source code, mimetype should be passed to Intent.

    Uri uri = Uri.parse("content://com.android.contacts/data/" + rawContactId);
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(uri, rawContactMimetype);
    

    And facebook messengers starts correctly