Java Code Examples for android.content.Intent.ACTION_CREATE_SHORTCUT

The following are Jave code examples for showing how to use ACTION_CREATE_SHORTCUT of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GravityBox   File:   Source Code and License Vote up 7 votes
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,
        // 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);
Example 2
Project: orgzly-android   File:   Source Code and License Vote up 6 votes
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);
        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);
Example 3
Project: XposedNavigationBar   File:   Source Code and License Vote up 6 votes
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 =;

        int flag = activityInfo.flags;
        String label = activityInfo.loadLabel(pm).toString();

        AppInfo appInfo = new AppInfo();

    return appInfoList;