Android创建桌面图标

来源:互联网 发布:网络电视剧排行榜2016 编辑:程序博客网 时间:2024/05/01 09:49
        Intent intent = new Intent();
        // 广播的频段
        intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        // 告诉Launcher我们的图标 名称 作用
        // 长啥样
        // 原图有些大 缩放一下
        Options opsts = new Options();
        opsts.inSampleSize = 4;
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
                R.drawable.girl, opsts);
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
        // 叫啥名
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "图标名称");
        // 干啥事
        Intent homepage = new Intent();
        homepage.setAction("包名");
        intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, homepage);
        // 告诉系统Launcher应用不去重复创建
        intent.putExtra("duplicate", false);
        // 发广播
        sendBroadcast(intent);
0 0
原创粉丝点击