1 year ago

#372002

test-img

Adam Burley

Does the equals method work for Activity objects in Android?

I looked in the Android source code and neither Activity nor any of its ancestor classes ContextThemeWrapper, ContextWrapper or Context override the equals method. Can equals be safely used to compare Activity objects?


Reason I want to do this: I have a notification queue that needs to be managed by the currently active activity. The activity will start managing it in its onStart and stop in its onStop. The problem is that in practice I have found when switching activities the new activity onStart can be called before the old activity onStop, and only one activity can be managing the notification queue at once. So I want to store a variable like "currentActivity" which activities can compare themselves to, to determine if some other activity onStart has already been called and therefore they don't need to take any action onStop.

android

android-activity

equals

0 Answers

Your Answer

Accepted video resources