总结(创建快捷方式等)

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"

 

posted @ 2013-09-02 22:59  雪地深处  阅读(217)  评论(0编辑  收藏  举报