安卓应用添加桌面快捷方式

Intent addIntent  = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
String title = getResources().getString(R.string.title_activity_result);
Parcelable icon = Intent.ShortcutIconResource.fromContext(MainActivity.this, R.drawable.qiang_ac);
Intent intent = new Intent(MainActivity.this,MainActivity.class);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,title);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,icon);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT
, intent);
sendBroadcast(addIntent);

 

posted @ 2018-01-17 07:43  欧阳平  阅读(738)  评论(0编辑  收藏  举报