Starting one activity brings all the other activities in the same process to front?

by krox » Wed, 21 Apr 2010 08:44:31 GMT


Sponsored Links
 Hi!

I have an application consisting of two activities (call them Display
and Preferences) and one service which listens for incoming
phonecalls. When it detects one it launches the Display-activity with
a delay of 3sec in order to let the PhoneApp launch first. The Display-
activity is transparent so the user can still use the PhoneApp as
normal (ie answering the call) even though my Display-activity is "on
top". So far so good :-)

Now to my problem. Lets say that the Preferences-activity is active
when there is an incoming call. The PhoneApp is launched on top of the
Preferences-activity as expected. However when the Display-activity is
launched the Preferences-activity pops up as well, hiding the
PhoneApp. My question is if it is possible to work around this in some
way? Since I do not want my Preferences-activity to block the PhoneApp
and hence making it impossible for the user to answer the incoming
phone call.

Kind regards,
Erik

--



Starting one activity brings all the other activities in the same process to front?

by Dianne Hackborn » Wed, 21 Apr 2010 09:24:41 GMT


 This is due to "task affinities."  By default all activities in an .apk have
the same task affinity, so that when one is launched it is associated with
any current task started via any other activities in the app.

If you publish multiple top-level activities in your app, you will probably
want to give them different task affinities so the system does not try to
treat them as part of the same logical flow.  This is accomplished with the
android:taskAffinity attribute in the manifest, as described here:

 http://developer.android.com/guide/topics/fundamentals.html #afftask

< http://developer.android.com/guide/topics/fundamentals.html #afftask>And
here:

 http://developer.android.com/guide/topics/manifest/activity-element.html #aff

Another place where it is useful to set the taskAffinity is for an activity
that is launched from a notification, so that it will be launched separately
from the main application and thus allow the user to press back to return to
whatever they were doing instead of having to go back through whatever is on
your main task's stack.  In this case you would set android:taskAffinity="",
saying that activity has no affinity to other activities.




>


Sponsored Links


Starting one activity brings all the other activities in the same process to front?

by krox » Wed, 21 Apr 2010 10:29:30 GMT


 Thanks!




> >



Other Threads

1. Does any developer in HongKong already get the seeding program device

Hi,
   I am in Hongkong and get the seeding program email at beginning of Mar,
then I submited my info and get confirmation at 12th Mar, the confirmation
said I would get the device in 2-4 weeks, but until now, I DID NOT get it, I
sent email to the seeding program email address, but the guy reply me said:
all the device were shipped already, I should patient and waiting the
device. but know 5 weeks past, I still did not get it. Does anybody in HK
get the device? how long you get it after the confirmation email?

  Thanks & Regards
Kevin

-- 

2. Layout not displayed properly while loading Listview dynamically?

Hi,

I am trying to laod the listview dynamically. There are three
textviews inside a listview. The text to be set in the textview is
fetched from the server. All this is working fine. I am able to fetch
the text and am able to display it inside the listview.

The only problem is the position of the textview. The xml layout file
is as under :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:id="@+id/listViewShow"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:background="@drawable/brown_bg"
    android:padding = "3dip">

    <TextView
        android:id = "@+id/txtBabbleListTitle"
                android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:textColor = "#000000"
                android:text = "Hello">
    </TextView>

    <RelativeLayout
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content">

        <TextView
                android:id = "@+id/txtBabbleDateTime"
                        android:layout_width = "wrap_content"
                        android:layout_height = "wrap_content"
                        android:layout_alignParentBottom = "true"
                        android:textColor = "#000000"
                        android:text = "Hello" >
        </TextView>
    </RelativeLayout>

    <TextView
        android:id = "@+id/txtBabbleTotalReplies"
        android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:layout_alignParentRight = "true"
                android:textColor = "#000000"
                android:text = "(7)">
    </TextView>

</RelativeLayout>

If I look at this xml layout in the eclipse layout tab then it is
displayed properly. Problem occurs only when the text is fetched
dynamically.

Can some one let me know the issue?


Thanks & Regards
Sunil

-- 

3. iPhone worshipper rejoice!

4. SOLD..WTS : HTC Desire BNIB (1unit).

5. HTC Hero Sprint 2n

6. Routing Audio data to Both HEADSET and SPEAKER.

7. No place in Google Checkout to set international tax rates. Do we owe? How to Pay?