2
我想在兩種不同的應用中同時使用Android中的陀螺儀傳感器。我知道它不需要在應用程序中綁定傳感器,所以我假設我們可以在兩個不同的應用程序中同時使用陀螺儀傳感器。我可以在android的兩個應用程序中同時使用陀螺儀傳感器嗎?
有人可以請指出我在正確的方向嗎?
我想在兩種不同的應用中同時使用Android中的陀螺儀傳感器。我知道它不需要在應用程序中綁定傳感器,所以我假設我們可以在兩個不同的應用程序中同時使用陀螺儀傳感器。我可以在android的兩個應用程序中同時使用陀螺儀傳感器嗎?
有人可以請指出我在正確的方向嗎?
你不能在兩個應用程序中同時使用任何東西,因爲android操作系統會在應用程序失去焦點後阻止應用程序工作。但是你可以用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
所以,你可以在同一時間,每個應用連續的數據流。