0

I have an application on google play. Once user download and installs, google play use to create a home screen widgets automatically (google play->settings->Auto-add widgets is checked). Due to some technical reasons I want to avoid this creation.

Is it possible to avoid this auto creation of home screen widget programmatically(through manifest or with any other options)?

Any answers will be highly appreciated, thanks in advance.

Daud Arfin
  • 2,499
  • 1
  • 18
  • 37

1 Answers1

0

Removing shortcut in Android uses an Intent (UNINSTALL_SHORTCUT) to perform the task.

So first add this permission to your manifest:

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

and in java code

 private void removeShortcut() {

//Deleting 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.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);

}

So now you can call it on ur first launch (may be when ur splash screen is loading, if you have any). Now its upto you how you utilize this :)

For more info.. http://viralpatel.net/blogs/android-install-uninstall-shortcut-example/ https://gist.github.com/zeuxisoo/1008973

Mohit
  • 2,940
  • 2
  • 24
  • 32
  • this can be done only when my application is launched atleast once but my question is about avoiding creation itself once after installation! – Daud Arfin Aug 28 '13 at 08:45
  • I don't think its possible like what you have planned or planning for .Its something that we as developers can't control. Even you can't fire up any service or BradcastIntent that could listen for install and fire up this code. Your users have to fire it manually once..see this http://stackoverflow.com/questions/8531926/how-to-start-a-service-when-apk-is-installed-for-the-first-time – Mohit Aug 28 '13 at 09:14