1

I am developing a app which will be distributed from my website. So when this app is installed the shortcut should be created in the home screen and i used the following code and it is creating shortcut icon when installed but with a toast message. I want to suppress this toast message. I am adding the function used to create shortcut home icon.

private void addShortcut() {
    //Adding shortcut for MainActivity 
    //on Home screen
    Intent shortcutIntent = new Intent(getApplicationContext(),
            MainActivity.class);

    shortcutIntent.setAction(Intent.ACTION_MAIN);

    Intent addIntent = new Intent();
    addIntent
            .putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(getApplicationContext(),
                    R.drawable.ic_launcher));

    addIntent
            .setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    getApplicationContext().sendBroadcast(addIntent);
}

I know the question is already asked but no answer . so i gave the question in a different way with code and Image.

enter image description here

Balaji Sabdhar M
  • 418
  • 1
  • 6
  • 26

2 Answers2

0

Looking the google's source of InstallShortcutReceiver it seems not possible (search for Toast).

Manuel Spigolon
  • 11,003
  • 5
  • 50
  • 73
  • the only thing with the above implementation is that toast message which from intent .my question is how to supress it – Balaji Sabdhar M Mar 05 '14 at 11:25
  • you send a broadcast intent. the class who recive that intent don't provide an EXTRA for not show the toast, so with your actual code you can't hide it – Manuel Spigolon Mar 05 '14 at 12:44
  • Finally the toast cannot be hide. Is there a way to to suppress all the toast message from any app – Balaji Sabdhar M Mar 05 '14 at 12:58
  • you can `cancel()` the Toast that you create, but there is no way for dismiss toast for other package name. But, you could add shortcut in homescreen [after installation](http://stackoverflow.com/questions/17102488/how-to-add-home-screen-shortcut-without-launching-app-after-installation) – Manuel Spigolon Mar 05 '14 at 13:05
0

From the research in android toasting , i have found that toast from the shorcut creation cannot be removed . If you are going through google store, then there is a option for creating shortcut icon in home screen. Then the toast will not come.

Balaji Sabdhar M
  • 418
  • 1
  • 6
  • 26