Java Code Examples for android.content.Intent#ACTION_CREATE_SHORTCUT

The following examples show how to use android.content.Intent#ACTION_CREATE_SHORTCUT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppPickerPreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 2
Source File: Launcher.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: LaunchShortcutActivity.java    From PhoneProfilesPlus with Apache License 2.0 6 votes vote down vote up
@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();
    }
}
 
Example 4
Source File: AppShortCutActivity.java    From XposedNavigationBar with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: AppUtils.java    From RelaxFinger with GNU General Public License v2.0 5 votes vote down vote up
public static List<ResolveInfo> getResolveInfos(){

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

        return resolveInfos;
    }
 
Example 6
Source File: LauncherModel.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: LauncherModel.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: LauncherModel.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
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;
}