当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ACTION_CREATE_SHORTCUT属性代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:18,代码来源:AppPickerPreference.java

示例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();
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:35,代码来源:BookChooserActivity.java

示例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;
}
 
开发者ID:EggUncle,项目名称:XposedNavigationBar,代码行数:28,代码来源:AppShortCutActivity.java


注:本文中的android.content.Intent.ACTION_CREATE_SHORTCUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。