Heavy-flavour hadrons, i.e. hadrons containing charm or beauty quarks, are effective probes to test perturbative-QCD (pQCD) calculations, to investigate the different hadronisation mechanisms, and to study the quark-gluon plasma (QGP) produced in relativistic heavy-ion collisions at the LHC. Measurements performed in pp and p-Pb collisions have recently revealed unexpected features not in line with the expectations based on previous measurements from e + e − and ep collisions, showing that charm fragmentation fractions are not universal. The investigation of initial-state effects such as shadowing in the collision of a proton with a heavy nucleus is also performed. Measurements of open heavy-flavour and quarkonia production in Pb-Pb collisions allow for testing the mechanisms of heavy-quark transport, energy loss, and coalescence effects during the hadronisation in the presence of a QCD medium. In this contribution, the most recent results on open heavy-flavour and quarkonia production in pp, p-Pb, and Pb-Pb collisions obtained by the ALICE Collaboration are discussed.