How To Find Back Stack Activities In An Android Application?
Solution 1:
The code below can be used to extract all the tasks and the top activity within each task in the back stack
ActivityManagerm= (ActivityManager) ctx.getSystemService( ctx.ACTIVITY_SERVICE );
List<RunningTaskInfo> runningTaskInfoList = m.getRunningTasks(10);
Iterator<RunningTaskInfo> itr = runningTaskInfoList.iterator();
while(itr.hasNext()){
RunningTaskInforunningTaskInfo= (RunningTaskInfo)itr.next();
intid= runningTaskInfo.id;
CharSequence desc= runningTaskInfo.description;
intnumOfActivities= runningTaskInfo.numActivities;
StringtopActivity= runningTaskInfo.topActivity.getShortClassName();
}
Solution 2:
You can use "adb shell dumpsys activity activities" command
for reference http://www.onsandroid.com/2015/01/find-back-stack-activities-in-android.html
Solution 3:
I think you can do it by listening to the changes of the activities, via this API of registerActivityLifecycleCallbacks :
https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html
This will help you to add to a stack of your own classes, and see the full state as you wish.
Solution 4:
I'm not sure i get it well...You want to go back to the previous activity ? If so, finish the current activity you'll get back to the previous one.
Solution 5:
actually, you can get the task id from the runningtaskinfo using getRunningTasks and then, get the recenttaskinfo using getRecentTasks by compare the task id. now you can restart that activity using startactivity, with the baseintent in the recenttaskinfo.
Post a Comment for "How To Find Back Stack Activities In An Android Application?"