public class Demoactivity extends Activity {
/** called when the activity is first created. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
}
public void Click (View view) {
// Intent Intent = new Intent ("Com.android.launcher.action.INSTALL_SHORTCUT");
// Intent dailintent = new Intent ();
// Dailintent.setaction (Intent.action_call);
// Dailintent.setdata (Uri.parse ("tel:110"));
// Intent.putextra (Intent.extra_shortcut_intent, dailintent);
// Intent.putextra (Intent.extra_shortcut_name, "call 110");
// Intent.putextra (Intent.extra_shortcut_icon_resource, R.drawable.ic_launcher);
// Sendbroadcast (Intent);
Intent Intent = new Intent ();
Intent.setaction ("Com.android.launcher.action.INSTALL_SHORTCUT");
Intent shortcutintent = new Intent ();
Shortcutintent.setaction ("cn.itheima.xxx");
Shortcutintent.addcategory (Intent.category_default);
Intent.putextra (Intent.extra_shortcut_intent, shortcutintent);
Intent.putextra (intent.extra_shortcut_name, "Test Fast");
Intent.putextra (Intent.extra_shortcut_icon,bitmapfactory.decoderesource (Getresources (), R.drawable.ic_launcher) );
Sendbroadcast (Intent);
}
}
Permissions Required:
<uses-permission android:name= "Com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission
Android Create Shortcut icon Demo