6

我目前正在开发一个 Android 应用程序,因此我以编程方式编写了一个到主屏幕的快捷方式。像这样的东西:

Intent shortcutIntent = new Intent();
shortcutIntent.setClassName(ai.packageName, ai.name);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.addCategory(Intent.ACTION_PICK_ACTIVITY);
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName);

BitmapDrawable bd=(BitmapDrawable)(res.get(app_id).activityInfo.loadIcon(p).getCurrent());
Bitmap newbit;
newbit=bd.getBitmap();
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newbit);

intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
context.sendBroadcast(intent);

(实际上是一个 StackOverflow 帖子,它向我指出了这个解决方案)。

无论如何,当我在模拟器中运行应用程序时,快捷方式被写入左侧第五页(在 2.3 主屏幕上)。随后的运行会将快捷方式写入主屏幕左侧的第 4 页。

我的问题是:有没有办法将快捷方式写入中心页面或第一页(例如传递似乎保存应用程序快捷方式的二维数组的索引)?我在 API 中遗漏了什么吗?

谢谢!

4

1 回答 1

9

您无法决定快捷方式的去向。

于 2011-03-17T22:56:18.920 回答