本文整理汇总了Java中android.content.Intent.ACTION_CREATE_SHORTCUT属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_CREATE_SHORTCUT属性的具体用法?Java Intent.ACTION_CREATE_SHORTCUT怎么用?Java Intent.ACTION_CREATE_SHORTCUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.ACTION_CREATE_SHORTCUT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ShortcutItem
public ShortcutItem(String appName, ResolveInfo ri) {
mAppName = appName;
mResolveInfo = ri;
if (mResolveInfo != null) {
mCreateShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
ComponentName cn = new ComponentName(mResolveInfo.activityInfo.packageName,
mResolveInfo.activityInfo.name);
mCreateShortcutIntent.setComponent(cn);
// mark intent so we can later identify it comes from GB
mCreateShortcutIntent.putExtra("gravitybox", true);
if (mAllowUnlockAction) {
mCreateShortcutIntent.putExtra(ShortcutActivity.EXTRA_ALLOW_UNLOCK_ACTION, true);
}
if (mLaunchesFromLockscreen) {
mCreateShortcutIntent.putExtra(ShortcutActivity.EXTRA_LAUNCHES_FROM_LOCKSCREEN, true);
}
}
}
示例2: onBookClicked
@Override
public void onBookClicked(long bookId) {
if (action != null && action.equals(Intent.ACTION_CREATE_SHORTCUT)) {
/* If this intent is used, shortcut's label will be overwritten (set to "Orgzly")
* with some launchers (like Nova) on every app update.
* It looks like it's due to setting action to ACTION_MAIN and category to
* CATEGORY_LAUNCHER (which main activity uses)
*/
// Intent launchIntent = Intent.makeRestartActivityTask(new ComponentName(this, MainActivity.class));
Intent launchIntent = new Intent(this, MainActivity.class);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
launchIntent.putExtra(AppIntent.EXTRA_BOOK_ID, bookId);
Intent shortcut = new Intent(Intent.ACTION_CREATE_SHORTCUT);
Shelf shelf = new Shelf(this);
String title = BookUtils.getFragmentTitleForBook(shelf.getBook(bookId));
if (title == null) {
setResult(RESULT_CANCELED, shortcut);
finish();
return;
}
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.cic_orgzly_logo_with_notebook);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
setResult(RESULT_OK, shortcut);
finish();
}
}
示例3: loadAppShortCut
private List<AppInfo> loadAppShortCut() {
//获取到所有快捷方式
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
List<ResolveInfo> shortcuts = getPackageManager().queryIntentActivities(
shortcutsIntent, 0);
List<AppInfo> appInfoList = new ArrayList<>();
PackageManager pm = getPackageManager();
for (ResolveInfo resolveInfo : shortcuts) {
ActivityInfo activityInfo = resolveInfo.activityInfo;
String pkgName = activityInfo.packageName;
String shortName = activityInfo.name;
int flag = activityInfo.flags;
String label = activityInfo.loadLabel(pm).toString();
AppInfo appInfo = new AppInfo();
appInfo.setLabel(label);
appInfo.setPackgeName(pkgName);
appInfo.setShortCutName(shortName);
appInfo.setFlag(flag);
appInfo.setType(AppInfo.TYPE_SHORT_CUT);
appInfoList.add(appInfo);
}
return appInfoList;
}