How do I Create Shortcut on android?

Get help using Construct 2

Post » Mon Sep 26, 2016 7:59 pm

Hi all,

I would know if it' s possible create a shortcut using Cordova plugin or something.

I would create a shortcut on android devices, I ' ve used this java code to do that usinf native java apps.

public void createShortCut(){
Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutintent.putExtra("duplicate", false);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcutname));
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext, R.drawable.icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext, EnterActivity.class));
sendBroadcast(shortcutintent);
}


Also I ' ve added permissions on manifest.xml

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


Thanks and greetens

David
B
10
S
1
Posts: 19
Reputation: 484

Return to How do I....?

Who is online

Users browsing this forum: blackhornet, Matei511 and 64 guests