Skip to content

Instantly share code, notes, and snippets.

@gshackles
Created May 18, 2012 03:39
Show Gist options
  • Save gshackles/2723016 to your computer and use it in GitHub Desktop.
Save gshackles/2723016 to your computer and use it in GitHub Desktop.
create a shortcut to the app on the homescreen
using System;
using Android.App;
using Android.Content;
using Android.OS;
[assembly: UsesPermission("com.android.launcher.permission.INSTALL_SHORTCUT")]
namespace AndroidApplication6
{
[Activity(Label = "AndroidApplication6", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var intent = new Intent(this, typeof(Activity1));
var installer = new Intent();
installer.PutExtra("android.intent.extra.shortcut.INTENT", intent);
installer.PutExtra("android.intent.extra.shortcut.NAME", "Start My App");
installer.SetAction("com.android.launcher.action.INSTALL_SHORTCUT");
SendBroadcast(installer);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment