Create a desktop shortcut

        Intent intent=new Intent();

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

// Prevent multiple shortcuts from being created
intent.putExtra("duplicate", false);

        //Shortcut name
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "vice");
        //Shortcut icon
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));

// Purpose of the shortcut

        Intent doWhatIntent=new Intent();
        //Tell the system to call
        doWhatIntent.setAction(Intent.ACTION_CALL);
        //Who to call
        doWhatIntent.setData(Uri.parse("tel://xxxx"));

// send broadcast

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


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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325413068&siteId=291194637