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. someone plz help me .. how to call built in camera app from my custom app ??

Do some debugging work...

The PackageManager can give you a list of all applications on your phone.
Step through them and find the Camera application and note the package name
of the camera application.

Assuming you have done that, you can do something similar to the following
(obviously putting in checks for the case the application doesn't exist,
etc...):

String packageName = <package name found in above steps>;
PackageManager mgr = getPackageManager();
Intent intent = mgr.getLaunchIntentForPackage(packageName);
startActivity(intent);

If the getLaunchIntentForPackage method returns null, as it sometimes does,
then you will have to create a new intent instead with something similar to
this:
Intent intent = new Intent();
intent.setClassName(packageName, className);

I have not looked into how to find the className of an arbitrary application
but I'm sure with a little work you can figure it out.

I have already explained to you how to do this, both in these forums and
when you emailed me directly.  Rather than continually posting the same
question over and over and waiting for someone to do your coding for you and
give you complete functional code, I would suggest looking through the
developer guide and the SDK reference docs and trying to figure it out for
yourself.

http://developer.android.com/reference/packages.html
http://developer.android.com/guide/index.html

Thanks,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------






--~--~---------~--~----~------------~-------~--~----~

2. Android Open-Source Project on devices

I think that its' a poor name choice for something that they don't  
want to be considered part of Android itself (especially as they like  
to claim they own the trademark, which is untrue in most of the world).

My guess it's an example of what happens when a marketing person gets  
to name an app without thinking about the bigger consequences.

Al.
--

* Looking for Android Apps? - Try http://andappstore.com/ *

======
Funky Android Limited is registered in England & Wales with the
company number  6741909. The registered head office is Kemp House,
152-160 City Road, London,  EC1V 2NX, UK.

The views expressed in this email are those of the author and not
necessarily those of Funky Android Limited, it's associates, or it's
subsidiaries.












--~--~---------~--~----~------------~-------~--~----~

3. File length is 0, which is not true... ?

4. How to find permissions required

5. Wallpapers for Android

6. GPS-Tracking application and telephone call

7. Cara rubah Magic jadi Hero