/**
* 生成快捷方式 */private void initShortCut() {// 开启一个intentIntent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");// 放置数据intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "黑马快捷方式");// 开启页面的信息Intent filter = new Intent("android.intent.action.HOME");filter.addCategory("android.intent.category.DEFAULT");intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, filter);// 发送快捷方式广播sendBroadcast(intent);}
开启的页面在清单文件得这样配置
<activity android:name="com.example.mobilesafe.AppProcessActivity" >
<intent-filter>
<action android:name="android.intent.action.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
权限
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />