【发布时间】:2017-03-16 08:20:39
【问题描述】:
我必须创建我的 android 应用程序快捷方式并将其放在主屏幕上的特定位置。
我能够通过以下代码成功地为应用程序创建快捷方式-
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "customizeScreenLayout");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.ic_launcher));
addIntent.putExtra("duplicate", false); //may it's already there so don't duplicate
getApplicationContext().sendBroadcast(addIntent);
我可以在上面的代码中添加什么,以便我可以将快捷方式放置在主屏幕中的特定位置(即,在特定的 x,y 坐标处)?
【问题讨论】:
标签: android positioning shortcut homescreen android-launcher