android.content.Intent#ACTION_CREATE_SHORTCUT源码实例Demo

下面列出了android.content.Intent#ACTION_CREATE_SHORTCUT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GravityBox   文件: AppPickerPreference.java
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 项目: TurboLauncher   文件: Launcher.java
/**
 * Process a shortcut drop.
 * 
 * @param componentName
 *            The name of the component
 * @param screenId
 *            The ID of the screen where it should be added
 * @param cell
 *            The cell it should be added to, optional
 * @param position
 *            The location on the screen where it was dropped, optional
 */
void processShortcutFromDrop(ComponentName componentName, long container,
		long screenId, int[] cell, int[] loc) {
	resetAddInfo();
	mPendingAddInfo.container = container;
	mPendingAddInfo.screenId = screenId;
	mPendingAddInfo.dropPos = loc;

	if (cell != null) {
		mPendingAddInfo.cellX = cell[0];
		mPendingAddInfo.cellY = cell[1];
	}

	Intent createShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
	createShortcutIntent.setComponent(componentName);
	processShortcut(createShortcutIntent);
}
 
@Override
protected void onStart()
{
    super.onStart();

    try {
        ComponentName componentName = new ComponentName(packageName, activityName);
        //intent = new Intent(Intent.ACTION_MAIN);
        Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        intent.setComponent(componentName);
        startActivityForResult(intent, 100);
    } catch (Exception e) {
        finish();
    }
}
 
源代码4 项目: XposedNavigationBar   文件: AppShortCutActivity.java
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;
}
 
源代码5 项目: RelaxFinger   文件: AppUtils.java
public static List<ResolveInfo> getResolveInfos(){

        Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
        List<ResolveInfo> resolveInfos = pm.queryIntentActivities(
                shortcutsIntent, 0);

        return resolveInfos;
    }
 
源代码6 项目: Trebuchet   文件: LauncherModel.java
/**
 * Returns a list of ResolveInfos/AppWidgetInfos.
 *
 * @see #loadAndBindWidgetsAndShortcuts
 */
@Thunk void updateWidgetsModel(boolean refresh) {
    PackageManager packageManager = mApp.getContext().getPackageManager();
    final ArrayList<Object> widgetsAndShortcuts = new ArrayList<Object>();
    widgetsAndShortcuts.addAll(getWidgetProviders(mApp.getContext(), refresh));
    Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
    widgetsAndShortcuts.addAll(packageManager.queryIntentActivities(shortcutsIntent, 0));
    mBgWidgetsModel.setWidgetsAndShortcuts(widgetsAndShortcuts);
}
 
源代码7 项目: TurboLauncher   文件: LauncherModel.java
public static ArrayList<Object> getSortedWidgetsAndShortcuts(Context context) {
	PackageManager packageManager = context.getPackageManager();
	final ArrayList<Object> widgetsAndShortcuts = new ArrayList<Object>();
	widgetsAndShortcuts.addAll(AppWidgetManager.getInstance(context)
			.getInstalledProviders());
	Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
	widgetsAndShortcuts.addAll(packageManager.queryIntentActivities(
			shortcutsIntent, 0));
	Collections.sort(widgetsAndShortcuts,
			new LauncherModel.WidgetAndShortcutNameComparator(
					packageManager));
	return widgetsAndShortcuts;
}
 
源代码8 项目: LB-Launcher   文件: LauncherModel.java
public static ArrayList<Object> getSortedWidgetsAndShortcuts(Context context) {
    PackageManager packageManager = context.getPackageManager();
    final ArrayList<Object> widgetsAndShortcuts = new ArrayList<Object>();
    widgetsAndShortcuts.addAll(AppWidgetManagerCompat.getInstance(context).getAllProviders());

    Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
    widgetsAndShortcuts.addAll(packageManager.queryIntentActivities(shortcutsIntent, 0));
    Collections.sort(widgetsAndShortcuts, new WidgetAndShortcutNameComparator(context));
    return widgetsAndShortcuts;
}
 
 方法所在类
 同类方法