创建桌面快捷方式

        Intent intent=new Intent();

        intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");

//防止创建多个快捷方式
intent.putExtra("duplicate", false);

        //快捷方式名字
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "vice");
        //快捷方式图标
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));

//快捷方式的用途

        Intent doWhatIntent=new Intent();
        //告诉系统想打电话
        doWhatIntent.setAction(Intent.ACTION_CALL);
        //给谁打电话
        doWhatIntent.setData(Uri.parse("tel://xxxx"));

//发送广播

intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, doWhatIntent);
        sendBroadcast(intent);


权限: <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>

猜你喜欢

转载自blog.csdn.net/vice_Q/article/details/50596234