Where to get the activity I'm currently in?
Here's my case
1. start main and the only activity of my app, the activity is almost empty at the startup moment 2. bind to a local service, which is nearly a wrapper of my legacy native library 3. all views will be dynamically created during runtime 4. it's service who determines when and how to build views, of course, mostly in native C++ code and JNI callsSo, I'm required to get a Context, actually current activity, since every constructor of Views requires a Context as a parameter. But how can I开发者_如何学C get the Context and cache it, if possible?
Thanks.
Bind to the service in your activity and pass a context in some method like
service.setActivityContext(this);
精彩评论