Closed alvis233 closed 2 years ago
Hey,
Thanks for checking out the project. I've been active on it today also so it's still changing.
The exception you're seeing for the unknown sensor is because I hardcoded the sensor name in the view, So it attempts to select that sensor. If you delete the sensor name from the layout it should start, allowing you to select the sensor from the dropdown in the actionbar. That list contains the actual sensors on your device. (The LSM6DS3 Gyroscope must be particular to my device I guess) I'll update the project to reflect this.
Regarding your issue reading the gyro sensor, your code looks about right. Check the sensor being returned from the sensorManager is not null. I think if the gyro is not enabled or not present, it;ll return null.
I ran the IDE in debug mode and called 'sensorManager.getSensorList(Sensor. TYPE_ALL)' to see what real sensors were present on my device. Make sure Gyroscope is present in that list.
Good luck with it.
On Fri, 20 Mar 2020 at 15:08, Alvis-is-coding notifications@github.com wrote:
Hey, bro, I saw you updated this project 3 hours ago, while I was trying to get the sensor data as you had done. I am a green finger, that's why I have failed so many times and turn to Github for help.I felt so excited and grateful to find your project. After I imported your project, I was awared there still existed some bugs. In the line 74 of EventManager.java, throw new IllegalArgumentException(String.format("%s is not a known sensor name")); it seems that you forgot to add , name. I fixed it, throw new IllegalArgumentException(String.format("%s is not a known sensor name", name)); but it still didn't work properly. The error read Caused by: java.lang.IllegalArgumentException: LSM6DS3 Gyroscope is not a known sensor name at org.spoofer.cockpit.events.EventManager.addListener(EventManager.java:74) I followed the 'https://developer.android.com/''s guide to do it by my own as below. ` @override https://github.com/override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); data = (TextView)findViewById(R.id.tv_data);
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
}
@override https://github.com/override public void onSensorChanged(SensorEvent event) { Log.e("onSensorChanged: ", event.values[0]+","+event.values[1]+","+event.values[2]); } Nothing just happened. Nothing appeared in the Logcat. I even tried to set text in the textviewdata`. It didn't work, either. ;( So, could you please help me? Or just some hints? Huge thanks!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/eurozulu/cockpit/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIAB4DM7AKKR4GJGJPYNW3RIN2E5ANCNFSM4LQMYHQA .
Hey,
Thank you very much for your reply.
I am new to Github. That's why I opened this issue by stating my problem in a such terrible format. Sorry for that.
I finally fixed my issue, although I don't know why. There is an Xposed framework in my device. But all the modules have nothing to do with the sensors. I was surprised to find everytime I open the Google Map, my APP could run as I expected. Of course the Google Map uses the Gyroscope to show the direction. So I wondered if I registered my listener successfully.
I removed the Xposed framework and everything went well. Nevertheless, your project is still helpful. I should devote myself in reading and learning your codes.
Again, thank you for your advice and your project.
Best regards.
Hey, bro, I saw you updated this project 3 hours ago, while I was trying to get the sensor data as you had done. I am a green finger, that's why I have failed so many times and turn to Github for help.I felt so excited and grateful to find your project. After I imported your project, I was awared there still existed some bugs. In the line 74 of
EventManager.java
,throw new IllegalArgumentException(String.format("%s is not a known sensor name"));
it seems that you forgot to add, name
. I fixed it,throw new IllegalArgumentException(String.format("%s is not a known sensor name", name));
but it still didn't work properly. The error readCaused by: java.lang.IllegalArgumentException: LSM6DS3 Gyroscope is not a known sensor name at org.spoofer.cockpit.events.EventManager.addListener(EventManager.java:74)
I followed the 'https://developer.android.com/''s guide to do it by my own as below.Nothing just happened. Nothing appeared in the Logcat. I even tried to set text in the textview 'data'. It didn't work, either. ;( So, could you please help me? Or just some hints? Huge thanks!