首页 > IT职业 > IT图书 > android创建app快捷方式
1.在清单文件中添加权限
2.在清单文件的activity节点添加意图过滤器(点击快捷方式打开的activity)
其中的action节点中的name属性自己定义,一般都是app的包名然后加点东西就行了
3.代码
//创建快捷方式private void installShortcut() {
Intent intent = new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "我的app");// 快解方式名称
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory
.decodeResource(getResources(), R.mipmap.app_icon));// 快解方式图标
Intent actionIntent = new Intent();
actionIntent.setAction("com.jaychan.demo.MAIN"); //需要和清单文件定义的那个action一致
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent);
sendBroadcast(intent);
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1976/viewspace-2813783/ ,如需转载,请注明出处,否则将追究法律责任。