Recent technology advances in wireless mobile communications, sensor networks, machine-to-machine communications, and Cloud computing enable a Cloud-centric Internet of Things (IoT) paradigm which may have a significant impact on development, deployment, and utilization of IoT applications. Device-to-Device (D2D) communication is an emerging technology for improving cellular networks, which play a crucial role in realizing such a new IoT paradigm. Resource allocation is a key technical issue for achieving high-performance data transportation in cellular networks with D2D communications. Game theory has been applied as an effective tool for addressing the problem of resource allocation for D2D communications in cellular networks. Our previous work  proposed a resource allocation scheme for intercell D2D communication, which introduced location-awareness in D2D resource allocation. In this paper, we extend our previous work by particularly analyzing the situations where the game model for D2D resource allocation does not have a Nash Equilibrium within the resource constraints given by the studied system. We model the resource allocation for such situations as a cooperative game between the base stations of two cells where a pair of D2D users are located, and develop an algorithm for determining the bandwidth allocation at each station for maximizing the total utility of both stations. Such an algorithm, with integrated with the resource allocation protocol developed in , enables a context-aware D2D resource allocation in cellular networks that choose different strategies for different system situations.