The growing affordability of smart phones and mobile devices has only added to this trend by encouraging prolonged durations of inactivity. In this paper, we present a middleware, called the Pervasive Middleware for Activity Recognition (PEMAR) that aims to increase the level of physical activity by creating a middleware for active games on mobile devices. For the PEMAR application, we present a human centered and adaptive approach that recognizes and learns human activities continuously by employing an activity library. The activity models in the library will be annotated with patterns of human activities and their contexts for general usage of activity models. This will be beneficial to many pervasive applications in terms of the availability of the accurate activity models as well as the reduction of burden for gesture training. The PEMAR middleware is composed of the following: (1) semantic models for human activity, (2) activity analysis, (3) activity recognition, (4) adaptation of motion models, and (5) motion based game applications. We evaluate the proposed PEMAR model in terms of its recognition accuracy and performance. In addition, we demonstrate the usage of the middleware through interactive activity gaming applications.