【发布时间】:2011-05-17 00:47:17
【问题描述】:
当用户第一次打开应用程序时,我有代码可以在主屏幕上创建应用程序的快捷方式。是否可以让应用程序对其进行设置,以便在用户打开应用程序时将快捷方式替换为小部件?
这是我用来设置快捷方式的代码
Intent shortcutIntent = new Intent();
shortcutIntent.setClassName(".BatteryWidget", "SampleIntent");
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.putExtra("someParameter", "HelloWorld");
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName);
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
this.sendBroadcast(addIntent);
-提前致谢。
【问题讨论】:
-
我正在努力解决同样的问题...
-
@TacBOsS,到目前为止,我已经阅读了很多关于它的内容,每个人都说这是不可能的。用户实际上必须手动完成。女巫是个无赖。
标签: android eclipse android-widget widget shortcut