Yos*_*ale 3 android cordova ionic-framework cordova-plugins
我正在为android编写一个离子应用程序(使用coffeescript和angular),我想在主屏幕上添加应用程序的快捷方式.谷歌没有帮助,这个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);
}
Run Code Online (Sandbox Code Playgroud)
还可以在AndroidManifest.xml中添加权限,如下所示:
<uses-permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission
android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
Run Code Online (Sandbox Code Playgroud)
另请参阅此链接的启动器源代码
| 归档时间: |
|
| 查看次数: |
2328 次 |
| 最近记录: |