简体   繁体   English

我可以在 android 中同时在两个应用程序中使用陀螺仪传感器吗?

[英]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.

相关问题 我可以在同一个 Spring Boot 应用程序上使用两个拦截器吗? - Can I use two interceptors on same spring boot application? 我可以在同一个Swing应用程序中使用两种不同的外观吗? - Can I use two different look and feels in the same Swing application? 如何在 Android Studio 的同一个项目中同时使用两个模拟器? - How to use two emulators at the same time in the same project in Android Studio? 如何在同一Java类中将两个传感器管理器用于加速度计和磁力计 - How to use Two Sensor Manager for Accelerometer and Magnetometer in the same Java class 两个线程可以同时使用同一套接字,这可能有问题吗? - can two threads use the same socket at the same time, and are there possible problems with this? 我可以获取应用程序的运行时间吗? [Android]产品 - Can I get the running time of an application? [Android] 我可以同时使用 implements 和 extends 吗? - Can I use implements and extends at the same time? 我可以在两个活动中使用相同的方法吗? - Can i use the same method in two activities? 我可以在同一个服务中使用两个存储库吗? - can i use two repository in the same service? 如何在单个 Android 应用程序中同时使用两个 firebase 项目? - How to use two firebase projects in single Android app at same time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM