|
|
3#

楼主 |
发表于 28-6-2013 11:58:01
|
只看该作者
本帖最后由 DDD888 于 28-6-2013 12:15 编辑
I found a method to install the shortcut on desktop.
Add this line into AndroidManifest.xml file.
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>
Here is the code.
var shortcutIntent = new Intent();
shortcutIntent.SetComponent(new ComponentName(this, Java.Lang.Class.FromType(typeof(ActivityHomeScreen))));
shortcutIntent.AddFlags(ActivityFlags.NewTask);
shortcutIntent.AddFlags(ActivityFlags.ClearTop);
Intent putShortCutIntent = new Intent();
putShortCutIntent.PutExtra(Intent.ExtraShortcutIntent, shortcutIntent);
// Sets the custom shortcut's title
putShortCutIntent.PutExtra(Intent.ExtraShortcutName, "test");
putShortCutIntent.PutExtra("duplicate", false);
putShortCutIntent.PutExtra(Intent.ExtraShortcutIconResource, Intent.ShortcutIconResource.FromContext(this, Resource.Drawable.Icon));
putShortCutIntent.SetAction("com.android.launcher.action.INSTALL_SHORTCUT");
SendBroadcast(putShortCutIntent); |
评分
-
查看全部评分
|