[英]Can I use gyroscope sensor in two application at same time in android?
I want to use the gyroscope sensor in Android simultaneously in two different applications.我想在两个不同的应用程序中同时使用 Android 中的陀螺仪传感器。 I know that it's not required to bind the sensor in an application so I am assuming that we can use the gyroscope sensor in two different applications at the same time.我知道不需要在应用程序中绑定传感器,所以我假设我们可以同时在两个不同的应用程序中使用陀螺仪传感器。
Can someone please point me in the right direction?有人可以指出我正确的方向吗?
You can't use anything in two applications at the same time because Android OS prevents applications to work after an app loses its focus.您不能同时在两个应用程序中使用任何内容,因为在应用程序失去焦点后,Android 操作系统会阻止应用程序运行。 But you can do it with 2 services
and you can fetch data from the application when needed.但是您可以使用 2 个services
来完成,并且您可以在需要时从应用程序中获取数据。
For example:例如:
//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
So you can have continuous data flow at the same time for each app.因此,您可以同时为每个应用程序提供连续的数据流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.