zoukankan      html  css  js  c++  java
  • 总结(创建快捷方式等)

    1、创建快捷方式

      

    public void checkShortCut() {
    
            SharedPreferences sp = PreferenceManager
                    .getDefaultSharedPreferences(this);
            // 是否在桌面上添加了快捷方式
            boolean never_check_shortCut = sp.getBoolean("never_check_shortCut",
                    false);
            // 存在快捷方式或者不允许添加,return
            if (never_check_shortCut) {
                return;
            } else {
                addShortcut();
                // 保存已经添加了快捷方式的信息,以便程序下次启动的不再提示
                Editor editor = sp.edit();
                editor.putBoolean("never_check_shortCut", true);
                editor.commit();
            }
        }
    private void addShortcut() {
            Intent shortcut = new Intent(
                    "com.android.launcher.action.INSTALL_SHORTCUT");
    
            // 快捷方式的名称
            shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                    getString(R.string.app_name));
            shortcut.putExtra("duplicate", false); // 不允许重复创建 
            Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
            shortcutIntent.setClassName(this, SplashActivity.class.getName());
            shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER);
            shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
            // 快捷方式的图标
            ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(
                    this, R.drawable.icon);
            shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
    
            sendBroadcast(shortcut);
        }

    2、设置ListView不显示分割线

      android:divider="@null"

  • 相关阅读:
    jQuery 笔记
    centos 项目上线shell脚本
    linux关于用户密码家目录总结
    python 写了一个批量拉取文件进excel文档
    css 选择器/table属性/type 属性
    表单
    html table
    html超文本标记语言
    mysql数据库1
    mysql数据库
  • 原文地址:https://www.cnblogs.com/snowspace/p/3297806.html
Copyright © 2011-2022 走看看