Recent emphasis on green communications has generated great interest in the investigations of energy harvesting communications and networking. Energy harvesting from ambient energy sources can potentially reduce the dependence on the supply of grid or battery energy, providing many attractive benefits to the environment and deployment. However, unlike the conventional stable energy, the intermittent and random nature of the renewable energy makes it challenging in the realization of energy harvesting transmission schemes. Extensive research studies have been carried out in recent years to address this inherent challenge from several aspects: energy sources and models, energy harvesting and usage protocols, energy scheduling and optimization, implementation of energy harvesting in cooperative, cognitive radio, multiuser and cellular networks, etc. However, there has not been a comprehensive survey to lay out the complete picture of recent advances and future directions. To fill such a gap, in this paper, we present an overview of the past and recent developments in these areas and highlight a number of possible future research avenues.