Skip to content Skip to sidebar Skip to footer

How To Know Activity Count Of My Application?

I am having multiple activities in my application. Please consider following case... Activity A calls Acitivy B. B calls C. When user presses back key C generates notification and

Solution 1:

One way is to push the shown Activity onto a stack (singleton) from onResume() in each of your Activities and pop it when 'Back' is pressed. That way, whenever 'Back' is pressed, you will know the current stack of Activities. As this will be shared by all the classes , it will help to store the values.

Solution 2:

If just count is the issue..create a static count variable in a class say Constants . or may be three of them..so whenever you go to a particular class..increment the corresponding static public variable.

Edit: You can also keep the count of activities in the shared preferences.

Post a Comment for "How To Know Activity Count Of My Application?"