List of usage examples for android.content Context SHORTCUT_SERVICE
String SHORTCUT_SERVICE
To view the source code for android.content Context SHORTCUT_SERVICE.
Click Source Link
From source file:com.android.contacts.DynamicShortcuts.java
public DynamicShortcuts(Context context) { this(context, context.getContentResolver(), (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE), (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE)); }
From source file:org.deviceconnect.android.deviceplugin.demo.DemoSettingFragment.java
@Override public void onAttach(final Context context) { super.onAttach(context); if (DEBUG) {//from w ww. j a va2 s. co m Log.d(TAG, "DemoSettingFragment: onAttach"); } if (mDemoInstaller == null) { mDemoInstaller = createDemoInstaller(context); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && mShortcutManager == null) { mShortcutManager = (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE); } }
From source file:com.android.contacts.ShortcutIntentBuilder.java
private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName, String lookupKey, byte[] bitmapData) { Intent intent = null;//from w ww .j av a 2 s.c om if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (BuildCompat.isAtLeastO()) { final long contactId = ContentUris.parseId(contactUri); final ShortcutManager sm = (ShortcutManager) mContext.getSystemService(Context.SHORTCUT_SERVICE); final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getQuickContactShortcutInfo(contactId, lookupKey, displayName); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } } final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); final Intent shortcutIntent = ImplicitIntentsUtil.getIntentForQuickContactLauncherShortcut(mContext, contactUri); intent = intent == null ? new Intent() : intent; final Bitmap icon = generateQuickContactIcon(drawable); if (BuildCompat.isAtLeastO()) { final IconCompat compatIcon = IconCompat.createWithAdaptiveBitmap(icon); compatIcon.addToShortcutIntent(intent, null, mContext); } else { intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); } intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); mListener.onShortcutIntentCreated(contactUri, intent); }
From source file:com.android.contacts.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); final Bitmap icon; final Uri phoneUri; final String shortcutName; if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); }/*from ww w . j a va2 s.c o m*/ if (Intent.ACTION_CALL.equals(shortcutAction)) { // Make the URI a direct tel: URI so that it will always continue to work phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null); icon = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.quantum_ic_phone_vd_theme_24); shortcutName = mContext.getResources().getString(R.string.call_by_shortcut, displayName); } else { phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null); icon = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.quantum_ic_message_vd_theme_24); shortcutName = mContext.getResources().getString(R.string.sms_by_shortcut, displayName); } final Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = null; IconCompat compatAdaptiveIcon = null; if (BuildCompat.isAtLeastO()) { compatAdaptiveIcon = IconCompat.createWithAdaptiveBitmap(icon); final ShortcutManager sm = (ShortcutManager) mContext.getSystemService(Context.SHORTCUT_SERVICE); final String id = shortcutAction + lookupKey + phoneUri.toString().hashCode(); final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getActionShortcutInfo(id, displayName, shortcutIntent, compatAdaptiveIcon.toIcon()); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } } intent = intent == null ? new Intent() : intent; // This will be non-null in O and above. if (compatAdaptiveIcon != null) { compatAdaptiveIcon.addToShortcutIntent(intent, null, mContext); } else { intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); } intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName); mListener.onShortcutIntentCreated(uri, intent); }
From source file:com.android.contacts.DynamicShortcuts.java
public static void reportShortcutUsed(Context context, String lookupKey) { if (!CompatUtils.isLauncherShortcutCompatible() || lookupKey == null) return;/*w w w . ja v a 2 s . co m*/ final ShortcutManager shortcutManager = (ShortcutManager) context .getSystemService(Context.SHORTCUT_SERVICE); shortcutManager.reportShortcutUsed(lookupKey); }