activityLauncher と同じようにすべてのアプリケーションを取得できる があります(または、アプリケーションにはGoogle マップのようAllAppsListに複数の がある可能性があるため、アクティビティと正確に呼ぶ必要があります)。activitiesそして、これactivityをブロードキャストしIntentて、これらのアプリケーションのショートカットを作成できます。私の問題は、作成されたショートカットに関するものです。これが私のコード作成ショートカットです:
public static void addShortcut(Context c, ActivityInfo actInfo){
    PackageManager pm = c.getPackageManager() ;
    String packageName = actInfo.packageName ;
    String className = actInfo.name ;
    CharSequence label = actInfo.loadLabel(pm) ;
    // Create an Intent to launch the application
    Intent shortcutIntent = new Intent (Intent.ACTION_MAIN) ;
    shortcutIntent.setComponent(new ComponentName(packageName, className)) ;
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP) ;
    // Create an Intent to notify Launcher to create a shortcut on home screen
    Intent addIntent = new Intent() ;
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent) ;
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label) ;
    // Put in the shortcut's icon
    Log.i(TAG, "use actInfo.loadIcon(pm)") ;
    Drawable drawable = actInfo.loadIcon(pm) ;
    Bitmap b = ((BitmapDrawable)drawable).getBitmap() ;
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, b) ;
    // Broadcast the Intent
    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    c.sendBroadcast(addIntent) ;
}
これにより、ホーム画面にショートカットを作成できますが、それらのアイコンのサイズはほとんど正しくありません。小さすぎるか大きすぎる可能性があります。この画像のように..上段は私が作成した2つのショートカットです。以下の 2 つのショートカットはランチャーからドラッグしAllAppsViewたもので、正常です。どうやら私のほうが小さいようです…
最初に試したのは、アイコンのサイズを変更することです。しかし、そうすると、作成されたアイコンは Launcher の AllAppsView からドラッグしたものほど完璧ではなくなります。つまり、あいまいになった。
別の試みはこのコードです:
 if (actInfo.icon != 0){
        Log.i(TAG, "use actInfo.icon") ;
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                Intent.ShortcutIconResource.fromContext(c, actInfo.icon)) ;
    }
    else if (actInfo.applicationInfo.icon != 0){
        Log.i(TAG, "use actInfo.applicationInfo.icon") ;
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                Intent.ShortcutIconResource.fromContext(c, actInfo.applicationInfo.icon)) ;
    }
here からですが、これも機能しません。
誰かが私に手を貸してくれることを願っています:)