在主屏幕上安装发射器图标一次发射器、图标、屏幕上

2023-09-05 06:14:39 作者:勿想勿念勿犯贱

当用户安装一个Android应用程序,启动程序图标在应用程序菜单中创建的。许多用户我跟期待,当他们安装的应用程序,图标会自动他们家的屏幕(发射台)上出现。

When a user installs an Android app, a launcher icon is created in the apps menu. Many users I talk to expect that when they install an app, an icon should appear automatically on their home screen ("launch pad").

很多的应用程序实现这一点不知。我的preference将有一个窗口出现安装询问用户是否要添加快捷方式?如果这是不可能的,任何code,它自动添加快捷方式就可以了。

A lot of apps achieve this somehow. My preference would be to have a window appear on install asking the user "Do you want to add a shortcut?" If that's not possible, any code that auto-adds the shortcut will do.

安卓给出了一堆code在这里:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LauncherShortcuts.html 这暗示,加入这个code(以及相关的XML)到项目会做的伎俩。但它没有我想要的效果。这似乎提供的code是被动的,我需要以某种方式触发它。

Android gives a bunch of code here: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LauncherShortcuts.html It is implied that adding this code (and the related xml) to your project will do the trick. But it does not have the effect I want. It seems the code provided is passive, and I need to trigger it somehow.

所以我的问题是:

我如何触发快捷的安装,以及如何确保它只会发生一次,preferably通过某种形式的应用程序安装触发的事件?

How do I trigger the installation of a shortcut, and how do I make sure it happens only once, preferably triggered by some kind of "app install" event?

PS: 一个复杂因素是,我建立我的应用程序中使用PhoneGap的,这意味着主要业务是不是活动,而是DroidGap。

PS: A complicating factor is that I am building my app using PhoneGap, meaning the main activity is not "Activity" but "DroidGap".

推荐答案

在这个例子中,它返回意图的setResult(... )。我相信你需要运行 sendBroadcast(意向)触发安装的快捷方式。

In the example, it returns the intent in setResult(...). I believe you need to run sendBroadcast(intent) to trigger installation of the shortcut.