我正在为
android编写一个离子应用程序(使用coffeescript和angular),我想在主屏幕上添加应用程序的快捷方式.谷歌没有帮助,this cordova/phonegap插件也无法正常工作.
有什么想法怎么做?
解决方法
从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); }
还可以在AndroidManifest.xml中添加权限,如下所示:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。