Search in sources :

Example 1 with OnShortcutIntentCreatedListener

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());
}
Also used : ShortcutIntentBuilder(com.android.contacts.common.list.ShortcutIntentBuilder) Intent(android.content.Intent) SpannableString(android.text.SpannableString) OnShortcutIntentCreatedListener(com.android.contacts.common.list.ShortcutIntentBuilder.OnShortcutIntentCreatedListener) Uri(android.net.Uri)

Aggregations

Intent (android.content.Intent)1 Uri (android.net.Uri)1 SpannableString (android.text.SpannableString)1 ShortcutIntentBuilder (com.android.contacts.common.list.ShortcutIntentBuilder)1 OnShortcutIntentCreatedListener (com.android.contacts.common.list.ShortcutIntentBuilder.OnShortcutIntentCreatedListener)1