ShutCut Menu

In order to Show ShutCut Menu When App Icon Long Pressed in your Sketchware project, use the codes provided below.

Step 1 :- Take A Add Source Directly Block And Put The Following Code In It.
android.content.pm.ShortcutManager shortcutManager = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
shortcutManager = getSystemService(android.content.pm.ShortcutManager.class);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (shortcutManager != null) {
This Code Will Give Promisson For Creating ShutCut Menu.
Step 2 :- Again Take A Add Source Directly Block And Put The Following Code In It.
android.content.pm.ShortcutInfo shutcut1 = new android.content.pm.ShortcutInfo.Builder(MainActivity.this, "Home")
.setShortLabel("Home")
.setLongLabel("Home")
.setRank(0)
.setIntent(new android.content.Intent(android.content.Intent.ACTION_VIEW, null, MainActivity.this, MainActivity.class))
.setIcon(android.graphics.drawable.Icon.createWithResource(MainActivity.this, R.drawable.default_image))
.build();
You Can Change The Code :-
1) Home
2) 0
3) MainActivity
4) default_image
5) shutcut1
The Code That Which You Can Change They In Red Colour.
Step 3 :- Take A Add Source Directly Block And Put The Following Code In It.
shortcutManager.setDynamicShortcuts(java.util.Arrays.asList(shutcut1));
}
}
else {
Toast.makeText(getApplicationContext(), "Pinned shortcuts are not supported!", Toast.LENGTH_SHORT).show();
}

Comments

Popular posts from this blog

Circle SeekBar

Textile