android 创建快捷方式图标

1、快捷方式权限:

    

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

 

2、创建步骤:

    

Intent addIntent=new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); 
				
				Parcelable icon = Intent.ShortcutIconResource.fromContext(ShortCutActivity.this, R.drawable.icon); //获取快捷键的图标          
				Intent myIntent=new Intent(ShortCutActivity.this, ShortCutActivity.class);           
				
				addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "快捷方式");//快捷方式的标题         
				addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);//快捷方式的图标            
				addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, myIntent);//快捷方式的动作           
				
				sendBroadcast(addIntent);//发送广播

 

你可能感兴趣的:(android)