本文整理汇总了Java中android.content.pm.ShortcutManager.isRequestPinShortcutSupported方法的典型用法代码示例。如果您正苦于以下问题:Java ShortcutManager.isRequestPinShortcutSupported方法的具体用法?Java ShortcutManager.isRequestPinShortcutSupported怎么用?Java ShortcutManager.isRequestPinShortcutSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.ShortcutManager
的用法示例。
在下文中一共展示了ShortcutManager.isRequestPinShortcutSupported方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pinShortcutToHomeScreen
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
private void pinShortcutToHomeScreen(Context context) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
ShortcutInfo pinShortcutInfo = createShortcutInfo(this);
Intent resultIntent = shortcutManager.createShortcutResultIntent(pinShortcutInfo);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, resultIntent, 0);
shortcutManager.requestPinShortcut(pinShortcutInfo, pendingIntent.getIntentSender());
} else {
Toast.makeText(context, R.string.device_does_not_support_shortcut_pinning, Toast.LENGTH_SHORT).show();
}
}
示例2: createPinnedShortcut
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
@TargetApi(26)
private void createPinnedShortcut(Card card, Icon icon) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
ShortcutInfo pin = new ShortcutInfo.Builder(context, card.getName() + "_pin")
.setShortLabel(card.getName())
.setIntent(createCardShortcutIntent(card))
.setIcon(icon)
.build();
shortcutManager.requestPinShortcut(pin, null);
}
}
示例3: removePinnedShortcut
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
@TargetApi(26)
public void removePinnedShortcut(Card card) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
List<String> toRemove = new ArrayList<>();
toRemove.add(card.getName() + "_pin");
shortcutManager.disableShortcuts(toRemove, context.getString(R.string.error_no_longer_in_library));
}
}
示例4: pinAppShortcut
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
public static void pinAppShortcut(Context context) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ShortcutManager mShortcutManager = context.getSystemService(ShortcutManager.class);
if(mShortcutManager.isRequestPinShortcutSupported()) {
ShortcutInfo pinShortcutInfo = new ShortcutInfo.Builder(context, "freeform_mode").build();
mShortcutManager.requestPinShortcut(pinShortcutInfo, null);
} else
U.showToastLong(context, R.string.pin_shortcut_not_supported);
} else
U.pinAppShortcut(context);
}
示例5: createOrRemoveRenameShortcutApi26
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
/**
* Create or remove rename shortcut from the home screen using ShortcutManager from API 25.
*
* @param create True if the shortcut should be created.
*/
@TargetApi(26)
private void createOrRemoveRenameShortcutApi26(boolean create) {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
if (create) {
String label = mApplication.getApplicationContext().getString(R.string.rename_shortcut_name);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, DSCApplication.ID_SHORTCUT_RENAME)
.setShortLabel(label)
.setLongLabel(label)
.setIcon(Icon.createWithResource(mApplication.getApplicationContext(),
R.drawable.ic_manual_rename))
.setIntent(getActivityIntent())
.build();
try {
shortcutManager.requestPinShortcut(shortcut, null);
mApplication.updateShortcutPref(TYPE.INSTALL);
updateShortcutFields();
} catch (IllegalArgumentException e) {
showAlertDialog(android.R.drawable.ic_dialog_info,
mApplication.getApplicationContext().getString(R.string.create_rename_shortcut_v26_error),
DO_NOT_SHOW_IGNORED);
}
} else {
shortcutManager.disableShortcuts(Arrays.asList(DSCApplication.ID_SHORTCUT_RENAME));
mApplication.updateShortcutPref(TYPE.UNINSTALL);
updateShortcutFields();
}
}
}