my dog learned polymorphism*
The moose likes Android and the fly likes How can i know current foreground activity(not from service)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "How can i know current foreground activity(not from service)?" Watch "How can i know current foreground activity(not from service)?" New topic
Author

How can i know current foreground activity(not from service)?

Balaji Khadake
Greenhorn

Joined: Apr 12, 2011
Posts: 3

Hi there..

I am having alert generation application. I want to start or switch to other(Third) activity from current activity(foreground) using another activity's context(middle). From current activity(foreground) i m switching to other(middle) activity using intents and from this switched activity again i m switching to another(third) activity using intents. Due to such scenario, i am getting little but flash of middle activity in between current foreground activity and final most(third) activity.
How can i resolve this one?

For this purpose i want to know current foreground activity or is there any other solution?

I am not having any ideas about this one. Highly appreciate solutions.

Thanks in advance


Thanks
Balaji
Johan Pelgrim
Ranch Hand

Joined: Jul 07, 2003
Posts: 105

Hi Balaji,

There is a topActivity field defined on the RunningTaskInfo class. You can get a list of running tasks via the getRunningTasks(int) method in the ActivityManager. Traverse through that list to find the currently active task by checking the topActivity field.

Regards,

Johan


Johan Pelgrim, The Netherlands
SCJP 1.4, SCWCD 1.4, SCBCD 5.0
Balaji Khadake
Greenhorn

Joined: Apr 12, 2011
Posts: 3

Johan Pelgrim wrote:Hi Balaji,

There is a topActivity field defined on the RunningTaskInfo class. You can get a list of running tasks via the getRunningTasks(int) method in the ActivityManager. Traverse through that list to find the currently active task by checking the topActivity field.

Regards,

Johan



Thanks a lot Johan...
Can i hide the middle activity view while switching from foreground activity view to third activity view because i m using intents?
Due to use of intents for switching activities i get flashing of middle activity's view which i don't want.
Johan Pelgrim
Ranch Hand

Joined: Jul 07, 2003
Posts: 105

Hi Balaji,

Maybe I don't really understand what you are trying to achieve. Basically you shouldn't interfere with which activity is placed before what other. You should let the ActivityManager take care of that for you. There is an AlarmManager in Android, which you can utilize to activate something at a certain point in time. Maybe that's what you need?

Cheers,

Johan.
Balaji Khadake
Greenhorn

Joined: Apr 12, 2011
Posts: 3

Johan Pelgrim wrote:Hi Balaji,

Maybe I don't really understand what you are trying to achieve. Basically you shouldn't interfere with which activity is placed before what other. You should let the ActivityManager take care of that for you. There is an AlarmManager in Android, which you can utilize to activate something at a certain point in time. Maybe that's what you need?

Cheers,

Johan.


Thanks Johan
i got what i want...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i know current foreground activity(not from service)?