Smartphones are not capable of competing against their desktop counterparts or servers in terms of CPU speed, battery, memory and storage. However, a mobile device can transparently use cloud resources by employing an offloading mechanism. Offloading enables mobile devices to run computation intensive applications such as object recognition, Optical Character Recognition (OCR) and augmented reality. In this paper, an Inversion of Control (IoC) based offloading technique is proposed in order to overcome shortcomings and limitations of current approaches in the literature. A sample application has been implemented by using the proposed technique. The results show that the proposed offloading technique leads to energy savings of 66% to 81% and execution time savings by 76% to 81% with a small computational overhead.