ITPub博客

首页 > IT职业 > IT图书 > android创建app快捷方式

android创建app快捷方式

IT图书 作者:54xx 时间:2021-09-09 09:52:15 0 删除 编辑

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);
}

原文链接:http://www.apkbus.com/blog-917772-68582.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1976/viewspace-2813783/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: CSS常见样式-2
请登录后发表评论 登录
全部评论

注册时间:2019-04-16

  • 博文量
    226
  • 访问量
    1612