1

I want to set my custom app widget to home screen. I have searched a lot and implement code and also run some demo But in all that what happen after click on button widget can't be set to home screen instead going to menu setting from device click on

Add->Widgets->Then my widget Icon

after click on my widget icon it will be set to home screen.

But i don't need this i want that after click on button from my activity widget will be set to home screen without going here.

Add->Widgets->Then my widget Icon

So please help me for this approach.

  • ok..to my guess, you have created custom app widget.and when you click on button the custom app widget has to be set to what...?here am not clear? – GvSharma Apr 21 '14 at 11:10
  • Possible duplication, answer might be here too https://stackoverflow.com/questions/16100926/how-to-add-a-widget-to-the-android-home-screen-from-my-app/44534896#44534896 – jsdario Jul 25 '17 at 10:41

1 Answers1

2

i want that after click on button from my activity widget will be set to home screen without going here

That is not possible.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So whenever I clicked on button this will be called and it will be compulsory Add->Widgets->Then my widget Icon?? –  Apr 21 '14 at 11:15
  • Because all data will be set dynamically to my custom widget from server and i wanted that if click on button it will be automatically set to home screen. But if it is not possible then any approach can you tell me please?? –  Apr 21 '14 at 11:19
  • @user3556371: "Because all data will be set dynamically to my custom widget from server" -- that is what [a configuration activity](https://developer.android.com/guide/topics/appwidgets/index.html#Configuring) is for. – CommonsWare Apr 21 '14 at 11:34
  • Means i have to register this activity as a configure in appwidget-provider and also in manifest file?? –  Apr 21 '14 at 11:57
  • I have checked whats app functionality, in that we can create programmatically widgets of contact. – Kimmi Dhingra Apr 26 '16 at 04:24
  • This is no longer correct – a number of applications actually do allow to create shorcuts and widgets programatically. Take many smart home apps, for instance. Here it is a link with further info https://stackoverflow.com/a/44534896/2633577 – jsdario Jul 25 '17 at 10:40
  • @jsdario: Please note that the link points to an answer about Android 8.0. At the time of this writing, that is on 0% of production Android devices, as Android 8.0 has not shipped. However, yes, over the span of the next several years, this feature will be available on more devices and be something practical for developers to use. – CommonsWare Jul 25 '17 at 10:59
  • @CommonsWare I am aware, it is a fair point, but even in Android 6/7 it is possible in apps such as Yeelight smart bulbs (disclaimer: not the developer) and furthermore I believe it has to do with the desktop app. – jsdario Jul 25 '17 at 11:27
  • @jsdario: If by "desktop app" you mean "home screen", it is certainly possible for home screen implementations to offer some sort of proprietary API with these sorts of capabilities. My guess is that only a tiny percentage of Android users have installed a home screen with that sort of API. – CommonsWare Jul 25 '17 at 11:57