Q. Android Appwidget not showing in launcher immediately after installation:-
What I have already tried and does not work consistently
Included stub Activity with MAIN and LAUNCHER intent filter
Included this code in onCreate() of this stub activity
sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));
What works consistently
Reboot
Change orientation of device with widget list opened. This causes a refresh of the widget list and shows the newly installed widget.
So is there something I am missing ? It creates poor perception when user installs widget and does not find the widget in the widget list. Generally leads to uninstall :(
This is an open issue for some devices and OS versions (mainly ICS it seems). What are you running? It should be the same issue which is, hopefully, soon fixed. I think the best option for you would be to inform your customers about this bug and that it is out of your hands. You should then also provide an easy way to fix it! An informed customer is less likely to have false expectations and uninstall your widget.
Related
I would like users to install the widget component of my app. Currently my "mainactivity" simply pops up a textview saying that there is a widget and to see their widget list.
Unfortunately right now, this requires them to open the mainactivity at all. If they want to see the widget in their list of widgets.
I don't want to do anything annoying, but there does seems like there are a lot of hurdles to actually getting and using a widget right now.
Things I could do: setup an onboot service that checks to see if the widget is on the launcher screen. It could remind users once or twice (ever) via some kind of notification. The widget can turn off that service using its onUpdate method or other lifecycle commands. I personally hate erroneous notifications.
One thing I'd like to do is programmatically open up the widgets list. is that possible? any other best practices? Since we can't have widget only apps anymore, I'd still like the main component of my app to be a widget.
setup an onboot service that checks to see if the widget is on the launcher screen
That will require the user to launch your activity, anyway, on Android 3.1+. Your "onboot service" will not run before then.
One thing I'd like to do is programmatically open up the widgets list. is that possible?
No. After all, the user has to indicate where on the home screen the app widget goes first.
any other best practices?
An app that is purely an app widget, unless it is blindingly obvious that it is only an app widget, is going to have these sorts of issues. That is why many app widgets are simply one piece of a more substantial app, so that if the user elects not to use your app widget, or does not notice that it is there, it is not that big of a deal.
I have a problem with a widget I have for an application.
If I put the widget on my homescreen, then I uninstall the application that my widget comes from, but the widget will not be removed on the homescreen. Instead of the widget there is a text saying: : "Loading".
Are there some kind of code I need to write so it gets removed when I uninstall the application on the phone?
I'm pretty sure the user has to manually remove widgets from the home screen. Here is a reference
You should package your widget and your app in the same APK. Then, when you uninstall the app, the widget will automagically get removed.
EDIT Unfortunately, I should have tested this before I posted. This does NOT work. You cannot programmatically remove the widget when the app is uninstalled. see this and this. 1000 Apologies for my incorrect advice :-(
I'm developing a widget which gets updated via intents. However, when the homescreen app (tested with ADWLauncher EX, the default Android homescreen and HTC Sense) is restarted, the widget is displayed with it's default layout, and no notification event is received to update the widget's content. No widget added or widget updated events/intents seem to get fired.
Is there any way for a widget to get notified when the homescreen app is restarted and the widget is (re)displayed?
Thanks!
There may not be a reliable way to detect launcher restart on all platforms. I have seen ONLY com.sec.android.widgetapp.APPWIDGET_RESIZE on Samsung Touchwiz android 4.0.4, and ONLY android.appwidget.action.APPWIDGET_UPDATE_OPTIONS on Jellybean 4.1.1, and nothing on several other builds I tested.
That said, when I encountered a problem similar to what you describe, the root cause was improper use of RemoteViews. Check your code to ensure you are only using one instance of RemoteViews for all updates. If you are continually using a new instance of RemoteViews in your code, many of the updates to your appwidget will be lost the next time it restarts.
Similar question: Widget not updated on launcher restart
I developed an APP + Home screen widget for Android. Now I updated the app (incremented the version code/name) but when i install, it doesn't automatically replaces the existing widget on screen. It just says "problem loading widget".
Any Idea??
Did you change the class name of the broadcast receiver implementing your widget? If so, don't do that.
There is of course the related use-case where there was a widget loaded on the home page and the user then uninstalls the application that contains the widget and widget config app. I guess this is the same as a new version which must to an uninstall/install cycle.
When that happens, all you see is the "Problem Loading Widget" in a toast-like box on the home screen. As far as I can tell, the widget gets no indicatation that the package is being uninstalled and I guess then the home screen AppWidgetManager thows up a default message.
Not well thought out behaviour on the part of the OS team. I suggest that it would be better to call the widget's onDisbled() and onDestroy() methods and to remove the widgets from the home screen before the package is removed so they can tidy up if need be and the user (non-geek phone user) gets a clean experience.
All I can find is the indication that only the user can remove a widget from the home screen, says commonsguy: Removing AppWidgets programmatically
I sure us developers can handle the odd weird toast, but for non technical "ordinary" phone users this sort of behaviour drives them back to iPhones very quickly.
This is the right behavior to me. As app is installed again, its widgets should be installed again too. If, for instance, there is a new activity to configure the widget, how do you know it as a user ?
There is, indeed, no way to guarantee that a new widget would run at all from this perspective.
When my application is uninstalled, a widget that is contained in this packages stays on the HOME
screen and gives an error message "problem loading widget".
How do I remove the widget when my application is uninstalled? Is there an
attribute in the manifest that I am missing?
I thought this thing should be handled by the OS, but guess it is not.
EDITED: I am now catching the "PACKAGE_ REMOVED" intent, and checking the "EXTRA_REPLACING" to make sure it's not a reinstall, but I don't know the actual code to use to actually remove the widget.
You cannot add or remove app widgets from the home screen. Only the user can do that.
Quoting #CommonsWare #4532121