You should also read the Application Fundamentals doc, which describes the
relationship between activities and tasks and how these are -not- related to
processes or threads:
http://developer.android.com/guide/topics/fundamentals.html

On Fri, Jun 26, 2009 at 4:18 PM, Doug <[email protected]> wrote:

>
> The startActivity() methods require the calling context to be an
> Activity - otherwise the 'FLAG_ACTIVITY_NEW_TASK' flag is required.
> This is why when you try to start an activity from the Application
> object, or a Receiver you must specify this flag.
>
> See:
> http://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent)<http://developer.android.com/reference/android/app/Activity.html#startActivity%28android.content.Intent%29>
> (note that it specifical mentions "This implementation overrides the
> base version, providing information about the activity performing the
> launch. Because of this additional information, the
> FLAG_ACTIVITY_NEW_TASK launch flag is not required")
>
> Doug
>
> On Jun 22, 9:37 pm, ani <[email protected]> wrote:
> > Guys,
> >
> > I would like to know the reason behind this behaviour.I have a
> > broadcast reciever and in onrecieve i am trying to start an
> > activity,however if i am not giving the flags it is giving an
> > exception .On declaring the flags it is working perfectly fine,why?
> >
> > I was under the impression that onRecieve runs in the main UI thread
> > and we can launch an activity in onRecieve.Error given by the emulator
> > is self explanatory but still why do i need to create an activity in a
> > new task(only in onRecieve)?
> >
> > onRecieve {
> > Intent intent4activity2 = new Intent
> > ("android.intent.action.activity2");
> > //intent4activity2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> > arg0.startActivity(intent4activity2);
> >
> > }
> >
> > regards,
> > ani
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
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