Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Shelby Kessel
PLUS
Shelby Kessel
Courses Plus Student 1,482 Points

Question About ShakeDetector Code

Hello, I have a quick question about the ShakeDetector.java file from "Shaking Things Up", when I placed the file in my com.example package in the src folder, two errors instantly showed up for lines 42, and 84. The code on 42 is "public void onSensorChanged(SensorEvent event)" and the code on 84 is "public void onAccuracyChanged(Sensor sensor, int accuracy)", the error for line 42 is "The method onSensorChanged(SensorEvent) of type ShakeDetector must override a superclass method"
and the error for 84 is "The method onAccuracyChanged(Sensor, int) of type ShakeDetector must override a superclass method" and when I went to quick fix them, the only quick fix is to remove the Override annotation, I tried removing the Override annotation to see if it would fix it and the errors are still there, I'm not sure if it will help but on the little icon on the left side of 42 also says "implements android.hardware.SensorEventListener.onSensorChanged" and "implements android.hardware.SensorEventListener.onAccuracyChanged" on line 84, so if anyone could help me out with this issue I would greatly appreciate it :)

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Check out this earlier post about this same issue: http://teamtreehouse.com/forum/adding-a-shake-detector

This appears to usually be a problem with project-specific compiler settings (read all the way to the bottom of the post).

Hope this helps!

Shelby Kessel
PLUS
Shelby Kessel
Courses Plus Student 1,482 Points

Yep that did it!, Thank You very much Ben for your help!