WeChat can add contacts directly to the desktop. Why do you click on the contact icon to directly enter the chat interface?

  android, question

As shown in the figure:

1. Open WeChat and click the target contact in the contact interface:

2. Click on the upper right corner of the contact details interface:

3. Select “Add to Desktop” at the bottom of the menu:

4. Contacts are added to the desktop:

5. Click the contact icon on the desktop to directly enter the chat interface:

* * My question is as follows:
Question 1: Why can you directly enter WeChat chat interface by clicking this icon? (I know this is a ShortCut, and what I want to know more is what kind of data this ShortCut’s Intent delivers, which enables me to directly open the dialogue window with the designated contacts on WeChat.)
Question 2: How to write a code to activate this “contact icon”? **

The official name of the Short Cut icon created by broadcasting is short cut.

Completing the addition of icons requires the following steps:

  1. Add permission<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

  2. Execute the following code

    //intent to add desktop icon
     Intent intent = new Intent();
     //Specify the desktop icon label
     intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "example");
     //Specify icon
     intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
     //Specify the intent of the action after the desktop icon is opened
     Intent value = new Intent();
     intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, value);
     //Send Broadcast

Among them, by setting the value of Intent.EXTRA_SHORTCUT_Intent as an intent, the next thing is the same as using INTENT to jump to an interface, so you can directly enter the chat interface.

If you need to jump to the corresponding session, you need to query the contact’s ContentProvider to obtain the contact’s ID, and then jump through Intent:

public final static String WEIXIN_CHATTING_MIMETYPE = "vnd.android.cursor.item/vnd.com.tencent.mm.chatting.profile";  //Wechat
 public static void shareToFriend(Context context,String id) {
 Intent intent = new Intent(Intent.ACTION_VIEW);
 ContactsContract.Data.CONTENT_URI, id),

In the same way, you can enter the contact’s circle of friends, conduct video chat and other actions. Because the contactId of the contact is a necessary parameter, it is usually used on the App related to the address book (I also learned from an address book App developed by the former company)