Android, Android App Development, Autocloseable.
networkConnection.disconnect(); networkConnection = null; } } } In this example, the close() method disconnects from the network if a connection exists. Now, you can utilize this view in a try-with-resources statement: try (NetworkImageView networkImageView = new NetworkImageView(context)) {