fun createShortcut(view: View) { val shortcutIntent = Intent("com.example.kelegorm.createhomescreenwidget.MainActivity") shortcutIntent.action = Intent.ACTION_MAIN val intent = Intent() intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent) intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)) intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher)) intent.action = "com.android.launcher.action.INSTALL_SHORTCUT" sendBroadcast(intent) }