Widget post-configuration - android

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.

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.

How to open activity when user will set widget on home screen?

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

How to add widget configuration activity to launcher?

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.

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