I'm guessing here a little bit, but is this what you want?:

The user is in ActivityA. THe user clicks on a button or does something 
that requires a background Thread to do so processing.
When the Thread is done (successfully), the thread needs to spawn/start 
ActivityB

If so,
use an AsyncTask. Subclass it into your own (static) subclass.

Create an instance of this class. When the task needs to run, instantiate 
it and call 'execute' on it.
This will cause its doInBackground method to run in a background thread.
When this method return, the onPostExecute is called. Use this to start 
ActivityB.

In the mean time, design your subclass to add a method that allows 
ActivityA to register itself (upon instantation/execute) and to deregister 
itself (e.g. when ActiivtA's onDestroy is called). If ActivityA is 
deregistered, you can code your subclass' doInBackground and/or 
onPostExecute method to stop or do nothing.


On Friday, September 7, 2012 2:16:52 PM UTC-4, bob wrote:
>
> The use case is that the thread may want to call Activity.startActivity().
>
> On Friday, September 7, 2012 11:35:50 AM UTC-5, Larry Meadors wrote:
>>
>> That's probably unsafe due to the lifecycle of activities. What's the use 
>> case? 
>>
>> Larry 
>>
>>
>> On Fri, Sep 7, 2012 at 10:18 AM, bob <b...@coolfone.comze.com> wrote: 
>> > What do you normally do on Android when you spawn a thread but the 
>> thread 
>> > needs to access 
>> > 
>> > your Activity object?  Do you typically pass the Activity object to 
>> your own 
>> > constructor for the Thread? 
>> > 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> > Groups "Android Developers" group. 
>> > To post to this group, send email to android-d...@googlegroups.com 
>> > To unsubscribe from this group, send email to 
>> > 
>> > 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to