Android 在爱奥尼亚+;科尔多瓦应用程序
我正在为android编写一个ionic应用程序(使用coffeescript和angular),我想在主屏幕上为该应用程序添加一个快捷方式。谷歌没有帮助,插件也不会工作Android 在爱奥尼亚+;科尔多瓦应用程序,android,cordova,ionic-framework,cordova-plugins,Android,Cordova,Ionic Framework,Cordova Plugins,我正在为android编写一个ionic应用程序(使用coffeescript和angular),我想在主屏幕上为该应用程序添加一个快捷方式。谷歌没有帮助,插件也不会工作 你知道怎么做吗?自从ICS以来,你可以这样做: public void createShortCut(){ Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortcutintent.put
你知道怎么做吗?自从ICS以来,你可以这样做:
public void createShortCut(){
Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutintent.putExtra("duplicate", false);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcutname));
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext, R.drawable.icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext, EnterActivity.class));
sendBroadcast(shortcutintent);
}
<uses-permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission
android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
还要在AndroidManifest.xml中添加权限,如下所示:
public void createShortCut(){
Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutintent.putExtra("duplicate", false);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcutname));
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext, R.drawable.icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext, EnterActivity.class));
sendBroadcast(shortcutintent);
}
<uses-permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission
android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
也请参考launcher的源代码:谢谢,但您的答案对本机android应用程序有效。我问的是一个ionic应用程序……我想他是在告诉你制作一个本机调用的插件。你是使用ionic+Cordova构建应用程序还是使用ionic CSS框架构建web应用程序?那么你必须有一个
.apk
文件(由构建->ionic构建android生成)。只需将其安装在手机/平板电脑上,您的应用程序就会显示其徽标…原生android行为会将应用程序放在应用程序抽屉中,而不是主屏幕上。当应用程序打开时,它可以将自己添加到主屏幕。这就是我想要的。