本文整理匯總了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();
}
}
}