我目前正在开发一个
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中的内容吗?
谢谢!
解决方法
您无法确定快捷方式的位置.