I'm trying to figure out how I can use a static abstract class as a callback. I'm looking at Android's documentation here and here. The first link is a CameraManager which has a method called openCamera. This method requires an instance of the static abstract callback class StateCallback.
My main question is, how does a static class as a callback provide me anything useful? For example, what I want to do is store the CameraDevice locally from the onOpened callback, but from what I know about static members in C# (I'm a C# dev), this would not be possible because static members cannot access non-static members.
I must not understand something about Java... Or is this an intended consequence of the API design?
Thanks in advance.
You need to extend it and create a new class that implements those methods, and pass that into the call. Because Java is all references, any parameter can be passed an object that derives from that class as well.
Also a static class in Java just means that it doesn't have a link to its parent object hidden inside of it. It makes it easier for the GC to collect instances. static in C#!=static in Java != static in C++ != static in C. Heck staic in most of those languages mean different things depending on where its used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With