Android写入到屏幕上,java – 如何以编程方式将快捷方式写入Android启动器主屏幕上的特定页面?...

我目前正在开发一个

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中的内容吗?

谢谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值