Skip to content

Instantly share code, notes, and snippets.

@GursheeshSingh
Last active April 23, 2019 18:45
Show Gist options
  • Save GursheeshSingh/511122050ced2c5c50a2432dfce890de to your computer and use it in GitHub Desktop.
Save GursheeshSingh/511122050ced2c5c50a2432dfce890de to your computer and use it in GitHub Desktop.
public class DatabaseLogger implements ILogger {
@Override
public void log(String message) {
//Log to Database here
}
}
public class FileLogger implements ILogger {
@Override
public void log(String message) {
//Log to File here
}
}
public interface ILogger {
void log(String message);
}
public class MainActivity extends AppCompatActivity {
private ILogger logger = new FileLogger();
@Override
protected void onCreate(Bundle savedInstanceState) {
logger.log("onCreate() starts");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
logger.log("onCreate() ends");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment