>> I posted this questions twice. I will really appreciate your help. Am I
>> asking very basic or vice versa? Or it is not possible in Android.
>> Please
>> help.

I cannot speak for anyone else, but I saw and skipped your previous
messages because you insist upon cross-posting to multiple lists, and I
get tired of it. Please only post to one list at a time.

You also reposted this twice within the past few hours. If you want that
fast of a response, please hire a consultant.

>>> The scenario is, I have an AsyncTask inside an activity_A. And on
>>> successful completion (means in onPostExecute) of this AsyncTask I want
>>> to
>>> show a dialog
>>>
>>> (AlertDialog.Builder builder = new
>>> AlertDialog.Builder(*Activity_A.this*);)
>>>
>>>
>>>
>>> But in the meanwhile(before completing this AsyncTask) if the
>>> application
>>> is moved to another activity_B. The above dialog context will not be
>>> the
>>> current Context so it will through an Exception.

Bear in mind that there may not be a "current Context". The user might
have exited your activity, for example. I am not aware of a 100% reliable
way to raise a dialog triggered asynchronously, such as in
onPostExecute().

One approximate answer is to have the activity register a listener object
with the service (e.g., in onCreate()) and unregister itself later (e.g.,
in onDestroy()). The service would call a method on the listener object
(if it is not null) to have the listener/activity raise the dialog.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to