How do I "pass an interface", i.e. what CommonsWare suggested to the asker in the question below?>
The other is to make DownloadFileTask public and pass something into the constructor. In this case, to minimize coupling, it may be that you don't want to pass an Activity, but some other sort of interface that limits what the AsyncTask can do. That way, you can choose to implement the interface on an Activity, or as a separate object, or whatever. – CommonsWare Apr 27 '10 at 17:44
How do I allow a thread to access to only some (or just one) of the objects public methods?
Answer> See the answers below.
The real problem was my misunderstanding of what an interface does. If the input type of a method F (or parameterization of a class) is specified as an interface [i.e. F(my_interface i)], and an object X is passed to that method which implements my_interface [F(X)], then only the members of X which implement my_interface will be accessible to the method F even if other members exist.
I thought an interface put a constraint only on the implementing class. I didn't understand that when an interface was used as a type it would also constrict access to the members of the implementing class. In retrospect, given that Java is statically typed this is obvious. See the Java tutorial for more info.