zoukankan      html  css  js  c++  java
  • android创建桌面快捷方式(启动目标非项目的启动页)

    1.布局文件中,目标Activity加入以下filter

        <intent-filter>  
                    <action android:name="android.intent.action.CREATE_SHORTCUT" />  
                    <category android:name="android.intent.category.DEFAULT" />  
                </intent-filter>

    2.通过发送广播的方式调用

          Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");  
                        shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.seckill));//设置快捷图标的名字
                        shortcut.putExtra("duplicate", false);//设置是否重复创建  
                        Intent intent = new Intent();  
                        intent.addCategory(Intent.CATEGORY_LAUNCHER);
                        intent.setClass(getActivity(), ProductListActivity.class);//设置第一个页面
                        shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);  
                        ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(getActivity(), R.drawable.wx_friend_non);//设置快捷图标的资源
                        shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);  
                        getActivity().sendBroadcast(shortcut);

  • 相关阅读:
    DOM操作——JavaScript怎样添加、移除、移动、复制、创建和查找节点
    Vue入门实战: 小白总结
    localStorage如何设置过期时间?
    北京游记-2019年小总结
    寒假宅家微记录
    SpringBoot 使用 swagger
    校园旧书交易交换平台
    Html 文件内容展示 图片展示
    Python 简易Cmd控制
    Python 多线程实现循环打印 abc
  • 原文地址:https://www.cnblogs.com/bravestarrhu/p/4494157.html
Copyright © 2011-2022 走看看