public boolean whatIsCurrentActivity()
{
ActivityManager am = (ActivityManager) mContext.getSystemService(mContext.ACTIVITY_SERVICE);
List ActivityManager.RunningTaskInfo taskInfo = am.getRunningTasks(1);
if(taskInfo != null ){
System.out.println("Top activity - Package name of the process is "+taskInfo.get(0).topActivity.getPackageName() );
}
All power is within you, you can do, anything and everything. believe in that do not believe that you are weak. You can do any thing and everything, without even the guidance of any one. Stand up and express the divinity within you. Within each of you there is the power to remove all wants and all miseries - Vivekanada
Monday, June 6, 2011
How to detect which is the current top activity.
Here is one of the way you can detect
Labels:
android-UI
Subscribe to:
Post Comments (Atom)
Very useful, always important to check null although ideally there should never not be a top Activity.
ReplyDeleteits returning my service's package . i need the package of application open just beneth the service.
ReplyDelete