0

我在 google play 上有一个应用程序。一旦用户下载并安装,谷歌播放使用home screen widgets自动创建(谷歌播放->设置->自动添加小部件被选中)。由于一些技术原因,我想避免这种创作。

是否可以通过编程方式(通过清单或任何其他选项)避免这种自动创建主屏幕小部件?

任何答案将不胜感激,在此先感谢。

4

1 回答 1

0

在 Android 中删除快捷方式使用 Intent (UNINSTALL_SHORTCUT) 来执行任务。

因此,首先将此权限添加到您的清单中:

<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />

在java代码中

 private void removeShortcut() {

//Deleting shortcut for MainActivity 
//on Home screen
Intent shortcutIntent = new Intent(getApplicationContext(),MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);

Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");

addIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);

}

所以现在你可以在你第一次启动时调用它(可能是在你的启动屏幕加载时,如果你有的话)。现在由您决定如何使用它:)

欲了解更多信息.. http://viralpatel.net/blogs/android-install-uninstall-shortcut-example/ https://gist.github.com/zeuxisoo/1008973

于 2013-08-28T07:54:57.887 回答