If you have a lengthy background process, I assume you're using a Service,
which already has a Context associated with it.
If you're not using a Service, you probably should be, then when you're done
post a notification to the user that their input is required to complete the
action, and when they click the notification, launch a new Activity (that
perhaps is styled to look like a popup dialog) that accepts the input you
need to complete the task.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Wed, Dec 2, 2009 at 11:12 PM, Mark Wyszomierski <[email protected]> wrote:

> Hi,
>
> I have some background task that is lengthy, long enough that it will
> see the passing of several activities. When finished, I need to prompt
> the user for some input. Is there a best-practice for keeping a
> 'foreground' context so I can launch an alert dialog from whichever
> context is currently being shown? I can do something like this:
>
>  public class ContextReference {
>      private static ContextReference mInstance;
>      private Context mContext;
>
>      public void onActivityResume(Context context) {
>          mContext = context;
>      }
>
>      public void onActivityPause() {
>          mContext = null;
>      }
>
>      public Context getContext() {
>          return mContext;
>      }
>  }
>
> then override every onResume()/onPause() pair in all activities in my
> application, have them each call the corresponding methods, this
> doesn't seem like a good idea though. Is there a specialized
> notification class for this sort of thing?  I also tried using a
> context stored at startup from getApplicationContext(), but when I try
> to use it with alert builder sometime into the life of my app, it
> appears to not work,
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to