1

I have a little problem with an alert View, the idea is that when the app starts, it asks on background for new data for the app, so after receiving the information an AlertView should be shown if there is new data. The problem comes because the AlertView is only shown on the main activity where I launched the asyncTask, so if I'm already in other activity, the alert will appear when I come back to the main activity and the Idea is that the AlertView is displayed in whatever activity the user is in.

My first thought was that the Context that I send to the AsyncTask is the problem so I've tried using getApplicationContext() so the app crashes in the moment of creating the alertView. So I'm, looking for a way to display this AlertView or something equivalent on the screen wherever he is on the app, does any one have ideas?

any idea would be greatly appreciated

Pedro Teran
  • 1,200
  • 3
  • 17
  • 43

1 Answers1

1

you can use broadcastreceiver in every activity which will contineous monitor your background service contineous whenever event occoured using broadcastreceiver display alertbox with content received by receiver.

MR. Kumar
  • 661
  • 8
  • 25
  • Thanks for the advice, but honestly I would prefer to avoid creating a broadcastReceiver for every activity since they are 30, and the app will become difficult to maintain since a change in the information received (that could happen in the future) I'll have to update 30 classes. – Pedro Teran Apr 25 '13 at 16:00
  • works! but I'm not happy of the solution I still while be searching for better alternatives. since with the intent the url that arrives from the json can be seen with an intent easily. and also, maybe i will have to change 30+ clases manually. – Pedro Teran Apr 25 '13 at 16:25
  • @Pedro Teran- actually i was not aware about how many activity your using. Now lets tell you another way , you will have to use two service ,and when 1st service complete your background task it will start another service and this service will have one method of displaying custom dialog using window manager or any other way which will popup on your activity whereever you will be.Hope it will solve your problem and if still confusion then ping me :) – MR. Kumar Apr 25 '13 at 17:10