"Do not place Android context classes in static fields; this is a memory leak (and also breaks Instant Run)" is shown while making any Android control static. Any better way to access an android control(like TextView) from other class other than creating an object of Parent class or making it(TextView) static?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I'm not sure if what you are doing is valid, but you can use an event bus, such as Otto to send events from objects to objects (such as from a Service to an Activity)
And you can have your own
Application
-derived object, this will be a singleton existing all the time while your program is alive, so you can have static fields in there.As we know, the
Application
orMultiDexApplication
class always remains active in memory, so we do not need to make our objects or variables as static, instead just declare them as normal(non-static) one, and call by creating an object of that application class, ie. instead of calling it directly as a static..and