Take the 2-minute tour ×

I have a problem that I have a widget that needs to make a http request using an activity and get some updates from internet.My problem is widget is doing the updates only using the activity.I put a button to start the activity but that's not the solution actually.I need that activity to start himself and terminate periodically when the widget is working.How can I achieve that?

share|improve this question
do you mean that you have show particular link. –  Nikunj Patel Jul 12 '11 at 10:56
Actually I'm downloading a json file with the request. –  nightmare17 Jul 12 '11 at 11:22
do you want to get data which are exist in json file? –  Nikunj Patel Jul 12 '11 at 11:28
yes but that's not the problem.Only widget is not enough.My widget couldn't make a http request, I think it's about widgets or I'm on the wrong way I don't know. –  nightmare17 Jul 12 '11 at 12:13
First tell me exactly what you want? proper description –  Nikunj Patel Jul 12 '11 at 12:21

2 Answers 2

up vote 0 down vote accepted

I think your idea of a widget is not right assuming you are talking about app widgets; a widget is basically just a view and nothing more, so it cannot request data from anything. If you want to update the data presented by the widget you can use a service to do the httprequest, and then serve it to the widget either by broadcasting your own action intent and handling that in the onRecieve of your AppWidgetProvider or update the widget directly.

Ofcourse if your activity is active it can update the widget as well, and you can start the activity by setting a repeating alarm in the AlarmManager, but if you don't have to display anything whilst doing the HttpRequest i would recommend against using an activity.

share|improve this answer

Your Answer


