How to reference the current or main activity from another class

后端 未结 13 1068
难免孤独
难免孤独 2021-01-30 12:39

I often find myself needing to access methods that require referencing some activity. For example, to use getWindowManager, I need to access some Activity. But ofte

13条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 13:07

    You can implement the necessary methods in your activity and implement a Handler. Then, simply pass a handler instance to your classes, where you can obtain a message for handler and send it to target.

提交回复
热议问题