我可以在Android的两个应用中使用陀螺仪传感器



我想在两个不同的应用程序中同时使用Android中的陀螺仪传感器。我知道不需要在应用程序中绑定传感器,因此我假设我们可以同时使用陀螺仪传感器。

有人可以向我指向正确的方向吗?

您不能同时使用两个应用程序中的任何内容,因为Android OS阻止了应用程序失去焦点后的应用程序。但是您可以使用2个services进行操作,并且可以在需要时从应用程序中获取数据。

例如:

//App1
    //Service1
        //read gyro data, write it to application space(db or sharedpreferences)
    //App1 Activity
        //read data from application space and show it to the user
//App2
    //Service2
        //read gyro data, write it to application space(db or sharedpreferences)
    //App2 Activity
        //read data from application space and show it to the user

因此,您可以同时具有每个应用程序的连续数据流。

相关内容

最新更新