How to add widget configuration activity to launcher? - android

I have a widget with a configuration activity.
Currently the configuration launches when you click on the widget.
I want to add the configuration as an app icon to the launcher.
The problem is that when the configuration launches on click, I get a specific widget id , so each widget instance can have a different configuration.
What will happen if I start the activity from the launcher?
I wont be able to show multiple configurations on the same activity.
Thanks.

What will happen if I start the activity from the launcher? I wont be able to show multiple configurations on the same activity.
Correct. Your choices appear to be:
Display a list of app widgets -- perhaps you have a database table matching up app widget instance ID to some sort of display name
You don't have the activity in the launcher. For example, put a configuration icon in the app widget itself.

Related

Creating a Widget only application in Android?

To clarify the question:
I have seen multiple Apps in the Playstore that are widget only Apps without visible activities.
I tried to create one myself but I need to define a launcher Activity. Once I use the configuration Activity of the Widget as a launcher the app becomes visible in the app overview in Android.
https://i.imgur.com/lhx0TDG.png
If I dont define a launcher Activity I cant even deploy the app on the emulator.
The developerguide on https://developer.android.com/guide/topics/appwidgets/index.html about Widgets isnt really clear about how to handle this case.
Any help or directions where to find information is appreciated.
If you want to create a widget only android application without any activity. You don't have to declare any intents for your activity. Just pass the intent filter for android.appwidget.action.APPWIDGET_CONFIGURE It will make the activity load when the user adds it to their home screen. Now you can simply declare your configuration class with your widget layout xml file with android:configure attribute liking to the class file the widget runs on.
Hope this helps.

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

Widget post-configuration

I'm writing an App Widget with configuration Activity. Everything works fine and a widget is correctly configured when I put it on the home screen.
Now, I want the user to be able to click on the widget and open again the configuration activity to change, for example, the text on the widget itself.
Do I have to store the new text on Preferences and force an update of the widget? Or is there a simpler way, for example accessing the RemoteViews directly on the configuration activity?
Thanks.

show spinner before adding widget android

For a widget I am creating for the Android OS, I want the user to first select a certain option from a Spinner. Just like when you add a shortcut to the homescreen.
Is that possible or do you have to start an Activity?
If it is possible, can anyone explain how to do it?
Spinner widgets do not exist on their own -- you have to have them in an Activity. Android's app widget framework supports the notion of a configuration activity that is automatically launched when somebody chooses your widget. Just put your Spinner in there.

Categories

Resources