mercredi 11 mars 2015

How to use static abstract class as a callback in Java?



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.




Aucun commentaire:

Enregistrer un commentaire