當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。