I did a sample from App Widget Article, Where I used Service for update the App widget.
Now I want to programatically update the App Widget from custom interval (run time interval).
How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is an example how to set create an update event for AppWidget. You can customize it for your purposes:
You should also make an additional intent-filter for your BR that will receive the intent with action name:
ExampleAppWidgetProvider.MY_INTENT_ACTIONUPDATE
To your Broadcast Receiver you should add new intent-filter like this:
Then you create an Intent that will be received by the defined intent-filter. In my case,
public static final String MY_INTENT_ACTION = "org.android.testwidget.MY_APPWIDGET_UPDATE";Data part of the Intent is needed to create a separate intent for each AppWidget instance (because I want to update each instance in different time). After that you create Pending intent for BR and create alarmManager with this PI. In the method
setRepeatingyou define the start time and the interval for your AppWidget instance.