Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Balaji Khadake
Greenhorn
Posts: 3
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Java Mac
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Balaji Khadake
Greenhorn
Posts: 3
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
Android Java Mac
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic