开发者

Starting quick contact from a home screen shortcut?

On several phones like a Nexus or a HTC phone you can add a quick contact shortcut to the home screen. When you press the persons image you get the little bouncy popup that has various icons in it. I am trying to duplicate this behavior.

Here is some logging of the intent that is fired when the quick contact is launched from a shortcut:

02-01 06:55:58.460: INFO/ActivityManager(1259): Starting activity: Intent { act=com.android.contacts.action.QUICK_CONTACT dat=content://com.android.contacts/contacts/lookup/2795i4464ea058cf583f3/177 flg=0x14200000 cmp=com.motorola.blur.contacts/com.android.contacts.ui.QuickContactActivity bnds=[18,253][108,340] (has extras) }

I have tried to duplicate this without success:

final Intent shortcutIntent = new Intent("com.android.contacts.action.QUICK_CONTACT");
shortcutIntent.addFlags(0x14200000);
Uri uri = Uri.parse("content://com.android.contacts/contacts/lookup/2795i694f803d0e56adba/182");
shortcutIntent.setData(uri);

final Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, contact.name);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, contact.icon);

This makes a shortcut just fine and the logs are almost identical except for the [extras]. I have not figured out what the extras I need to be sending.

02-01 07:01:53.147: INFO/ActivityManager(1259): Starting activity: Intent { act=com.android.contacts.action.QUICK_CONTACT dat=content://com.android.contacts/contacts/lookup/2795i694f803d0e56adba/182 flg=0x14200000 cmp=com.motorola.blur.contacts/com.android.contacts.ui.QuickContactActivity bnds=[245,252][355,382] }

02-01 07:01:53.280: ERROR/AndroidRuntime(12317): java.lang.NullPointerException
02-01 07:01:53.280: ERROR/AndroidRuntime(12317):     at com.android.contacts.ui.QuickContactActivity.onNewIntent(Qu开发者_如何学运维ickContactActivity.java:77)

Does anyone know the correct way to call the quick contact from a shortcut or what the extras I need to send are?


Use intent.putExtra(ContactsContract.QuickContact.EXTRA_MODE, QuickContact.MODE_SMALL);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜