How to migrate old widgets into a new one - android

The app I am wrorking on has three widgets right now. Each of these widgets has a different size and a fix layout file.
Now I've developed a new widget which is resizable and adaptive. It loads a fitting layoutfile according to its size.
Now with the next update with my app I would like to achieve the following:
List only the new adaptive widget in the widget drawer, so the old widgets cannot be created
Already existing widgets shall use the logic of the new widget to update their views
Right now I think that these two goals contradict each other. When I delete or disable the widget receiver from the manifest the widget disappears from the widget drawer but on the same time the existing widget on the homescreen breaks.
When I let the existing widget provider use the new logic the old widgets behave like the new one but on the widget drawer I've got four times the same widget.
Is there a way to achieve my goals? If not, is it possible to hide the old widgets for new users while they will be there for extings users who are updating their app?
Thanks a lot for your answers!

There is no solution to this. When you move the package name of the widget provider the widget gets deleted.
I settled on using one provider of my old widgets which got migrated to the new one. The other three were deleted.

Related

How can i make widget of any ListView item?

I am working on the Note's application. In my appication i want to add the functionality like ColorNotes and Notes app. When i long click to any listview item then it should become the widget on main screen.
How can i build such functionality ?
you can use below link to Learn App Widget
https://developer.android.com/guide/topics/appwidgets/index.html
Use this Example for Sample this will help you to understand how will use list in Widget
https://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/LoremWidget
I am going to assume that those are screenshots of Android home screens, showing some app widgets.
You cannot cause an app widget to be added to the home screen. After all, not all home screens offer app widgets. The user would have to set up the app widget themselves.
Given that the user set up the app widget, you are welcome to populate it based on a long-click of a list row in one of your activities. Use AppWidgetManager and updateAppWidget() to push a new RemoteViews to the app widget based on what the user long-clicked on.

Add widget name to the home screen along with widget

I have created a widget for an application. And widget is displaying along with the name under widget tab. When I drag the widget onto the home screen, the name below the widget is missing.
I have already set the label property for the <receiver></receiver>.
Is there anything else I need to do or any other configuration to change?
Regards.
You can set the name of your app widget to be displayed in the widget
picker by adding android:label="the name of my appwidget" to the
receiver that handles appwidget related intents in
AndroidManifest.xml. It is documented in a somewhat obscure place:
http://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo.html#label
How do I give a Android App Widget a Label/Name
Sorry to say that, it is not possible, because widgets name will be shown in only widgets menu not on home screen in many launchers, But you can use Shortcuts.
Shortcuts show the name with icon, they are simple, all data (icon, label, intent) is static, determined at creation time. They can't be updated dynamically, or resized, or scroll. But they match the launcher styling (and can be placed inside folders or the dock) and use less resources than AppWidgets.
As #kevin TeslaColl suggested, you should use Shortcuts
If you want a label to appear bellow the widget when its placed on the home screen, just place a TextView on your widget xml layout with the label you want

How do you use Configuration Activity to choose different size widgets?

How do I allow users to choose different size widgets using a configuration activity? I know this question has been asked a ton on here and the simple answer is: You can't do it.
The size is determined in the < appwidget-provider > and can't be changed at run time. The work around is to have multiple appwidget-providers with different sizes, and you pick the size you want when you go to add the widget to the home screen.
I am not happy with this solution. The Widget menu should not be cluttered with different size widgets that do more or less the same thing.
I'm trying to think of a work-around and I have an idea but I don't know how to implement it, if it's even possible.
What I'm thinking is this: You have a widget that opens a configuration activity. When the user selects the widget they want instead of setting the result to RESULT_OK and giving it the widget that was configured, what if you set the result to RESULT_CANCELED (so no widget is created) and start a new intent that triggers a new appwidget-provider that does contain the size you want?
Would that be possible?
If so, how?
And could you hide the different size appwidget-providers from the add widget menu? The whole idea is to not clutter it.

Embed custom view in android home screen widget

I am building a home screen widget and I want to add an advertisement to it. Currently the advertises SDK provides a custom view widget which I tried to embed in my home screen widget. But when I add it, it says problem loading widget. I'm guessing I can't add custom views to a widget? Could someone clarify or tell me how I could add an advertisement to my home screen widget.
Thank you
Home screen widgets support very limited number of standard widgets. You can't use custom widgets for them. See App Widgets.

Using a Widget in Activity

it's me again :-)
Is there a way to use a widget (for home screen) in my own activites?
i think the homescreen is made with java, too?!
i do not want to change thinks in the widget, i still want to display them.
Regards
FLy
If you are looking to "re-use" a widget's layout and may be its base code, that is possible. I don't think it will be a good idea [or possible] to display a widget as an activity.
There are a lot of limitations in the number of view elements that can be used inside a widget. And again the way you will update a widget [RemoteViews] is actually very different from that of an Activity.
So in short, the answer would be a "NO".
Edit: This question has also been asked and answered a lot of times: difference between view and widget

Categories

Resources