Relationships among apps, tasks, and activities

by Dianne Hackborn » Sat, 02 May 2009 13:10:13 GMT

Sponsored Links
 The behavior you are describing is not how things work.  What do you mean
you don't see another task?  How are you telling?  "adb shell dumpsys
activity" will show you the current activity state with the exact task
organization (in the first part of the output).

Dianne Hackborn
Android framework engineer

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.


Relationships among apps, tasks, and activities

by devi prasad » Sat, 02 May 2009 13:30:12 GMT

 Hi, Dianne: ok, thanks.
I use the following functions to determine the task id and if it is
the root of a task:


I used logcat looking for useful hints. Let me see if I understand it
better if I use
"adb shell dumpsys activity"


Sponsored Links

Relationships among apps, tasks, and activities

by devi prasad » Sat, 02 May 2009 16:07:44 GMT

 Hi, Dianne: this is the portion of the dump that I get by executing
"adb shell dumpsys activity" :
Activities in Current Activity Manager State:
    Task{3 com.robosoft.example}
    clearOnBackground=false numActivities=3 rootWasReset=true
    intent=Intent { action=android.intent.action.MAIN

comp={com.robosoft.example/com.robosoft.example.AppRootActivity} }

    History #3:
        packageName=com.robosoft.example processName=com.robosoft.example
        app=ProcessRecord{43516130 181:com.robosoft.example/10018}
        Intent { flags=0x10000000
        comp={com.robosoft.example/com.robosoft.example.SingleTaskActivity} }

    History #2:
        packageName=com.robosoft.example processName=com.robosoft.example
        app=ProcessRecord{43516130 181:com.robosoft.example/10018}
        Intent {
comp={com.robosoft.example/com.robosoft.example.ChildActivityOfRoot} }

    History #1:
        packageName=com.robosoft.example processName=com.robosoft.example
        app=ProcessRecord{43516130 181:com.robosoft.example/10018}
        Intent { action=android.intent.action.MAIN
As I gather, this shows that all three activities are part of the same
task, even though I use FLAG_ACTIVITY_NEW_TASK while starting
'SingleTaskActivity' and mark it with 'singleTask' launch mode. The
intent flag value (0x10000000) indicates this in the top most activity
entry above.

I cannot explain this behavior with my current understanding derived
from the documentation. What am I missing here?



Relationships among apps, tasks, and activities

by devi prasad » Sun, 03 May 2009 07:47:53 GMT

 ell, I DO think that Android documentation speaks about tasks and
their affinities, contrary to what I said previously :)

I defined a non-default value for the taskAffinity attribute of the
activity in question:
<activity android:name=".SingleTaskActivity"

and the activity gets to run in a separate task.

Both 'taskAffinity' and 'launchMode' are necessary if we want to have
an activity run in a separate task. Alternatively,
Intent.FLAG_ACTIVITY_NEW_TASK may be used in the intent, in case only
'taskAffinity' is mentioned in the manifest.

This is really interesting :)

On Sat, May 2, 2009 at 1:37 PM, devi prasad <> wrote:


Relationships among apps, tasks, and activities

by devi prasad » Sun, 03 May 2009 08:14:54 GMT

 ome more thoughts...
What I've said about taskAffinity and launchMode attributes, in
general, makes sense when the activities are in the same app since the
default value of taskAffinity will be set to the package name. When
the activities across apps activate one another, just the launch mode
value tells if the launched activity would be the root of the new
task. Again, this is because the package names of the apks would be

On Sun, May 3, 2009 at 5:17 AM, devi prasad <> wrote:


Other Threads

1. Android 2.2 - Portable Hot Spot - WifiManager class

I'm looking at how Android supports wifi portable hot spot
functionality with a view to writing simple home screen widget that
allows people to turn the phone's wifi hotspot on and off without
digging into the device settings.

There was nothing obvious at so I dug through my
copy of the Android source code and found that the WifiManager class
( provides the basics to allow the state
to be queried. So as well as 'getWifiState()' there is
'getWifiApState()' and a matching set of state constants.

However, in my bang-up-to-date Eclipse IDE, this class has none of the
Ap methods or constants. Can anyone shed any light on this?



2. Having camera store snapped pictures

Hey all -

I am working on a program that opens up the camera on a button click,
snaps a photo and takes that photo and stores it in a new class
( that will be accessed from the main menu.  My code to
snap a pic is:

        protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
                if (resultCode == RESULT_CANCELED) {
                        showToast(this, "Scan Cancelled");
                if (requestCode == CAMERA_PIC_REQUEST) {
                        Bitmap thumbnail = (Bitmap) 
                        ImageView image = (ImageView) 


how do I go about saving that new bmp file to that different class?

I tried to put photoResultView in my class as so:

                TextView label = (TextView) rowView.findViewById(;
                // Change the icon for pics snapped, tester for later 
                if (names[position].startsWith("pic7")
                                || names[position].startsWith("Slut8")) {
                        ImageView imageView = (ImageView) rowView

but the program crashes everytime I try and save the pic I snapped -
anyone have any ideas or tutorials for doing this?



3. how to enable iptables in froyo

4. usb keyboard in froyo

5. Install aplikasi di sdcard

6. select query problem.

7. Fwd: Kurikulum Android dari Meruvian Education