use of com.android.contacts.common.list.ShortcutIntentBuilder.OnShortcutIntentCreatedListener in project packages_apps_Contacts by AOKP.
the class QuickContactActivity method createLauncherShortcutWithContact.
/**
* Creates a launcher shortcut with the current contact.
*/
private void createLauncherShortcutWithContact() {
final ShortcutIntentBuilder builder = new ShortcutIntentBuilder(this, new OnShortcutIntentCreatedListener() {
@Override
public void onShortcutIntentCreated(Uri uri, Intent shortcutIntent) {
// Broadcast the shortcutIntent to the launcher to create a
// shortcut to this contact
shortcutIntent.setAction(ACTION_INSTALL_SHORTCUT);
QuickContactActivity.this.sendBroadcast(shortcutIntent);
// Send a toast to give feedback to the user that a shortcut to this
// contact was added to the launcher.
final String displayName = shortcutIntent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
final String toastMessage = TextUtils.isEmpty(displayName) ? getString(R.string.createContactShortcutSuccessful_NoName) : getString(R.string.createContactShortcutSuccessful, displayName);
Toast.makeText(QuickContactActivity.this, toastMessage, Toast.LENGTH_SHORT).show();
}
});
builder.createContactShortcutIntent(mContactData.getLookupUri());
}
Aggregations