标签:
<!-- Intent received used to install shortcuts from other applications --><receiverandroid:name="com.android.launcher2.InstallShortcutReceiver"android:permission="com.android.launcher.permission.INSTALL_SHORTCUT"><intent-filter><action android:name="com.android.launcher.action.INSTALL_SHORTCUT" /></intent-filter></receiver><!-- Intent received used to uninstall shortcuts from other applications --><receiverandroid:name="com.android.launcher2.UninstallShortcutReceiver"android:permission="com.android.launcher.permission.UNINSTALL_SHORTCUT"><intent-filter><action android:name="com.android.launcher.action.UNINSTALL_SHORTCUT" /></intent-filter></receiver>
public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}public void createShortcut(View view){//1.调用系统的提供的创建快捷方式的功能Intent intent = new Intent();intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");//2.给快捷方式设置名称intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "女神求救神器");//3.给快捷方式设置图标intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.safe));//4.设置快捷方式的功能Intent c = new Intent();c.setAction(Intent.ACTION_CALL);c.setData(Uri.parse("tel:110"));//添加快捷方式功能的意图intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, c);//5.调用系统提供的创建快捷方式的意图sendBroadcast(intent);}}
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
标签:
原文地址:http://www.cnblogs.com/candledragle/p/4260971.html