I want to create an android widget like CNN app widget. Let me explain you the follow of widget. I set on variable on shared preference to store category value if its null than open one activity which has list to select category and than load the data according to that category in widget. I put my code on onUpdate even in widget it will load data according to the category its working fine but my problem is when i am going to set my widget i just click on it and it will open the activity after i select the category it will close category activity but widget is not set on home screen so for that i have to again to the widget menu have to pic the widget and drop on the homescreen.
so i want to open my category selection activity when user drop the widget on home screen. I google a lot but not find any solution for it. please help me out. Thank you in advance.
You need to set the configure Activity to the widgets's xml file like this:
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure="your.package.your.activity"
.... />
Here is the official documentation regarding this topic:
https://developer.android.com/guide/topics/appwidgets/index.html#Configuring
Related
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.
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
I have created a Widget in android. By clicking that widget I am launching an activity, from there the user can choose any of the item displayed there in the list list view. I am storing the selected item in a shared preference. But the value the user have changed is not updating in the widget until i am re installing the widget. I want to update the widget by code. Is that possible ?
Yes, of course. Here you can find detailed simple example including the code samples: http://developer.android.com/guide/topics/appwidgets/index.html#UpdatingFromTheConfiguration
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.
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.