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

Shake Detector error in MainActivity.java

I know this problem has come up before, but searching the forums, I have not found the answer that my app would be satisfied with.

Ever since adding the code for the shake detector, I've had a red wavy line under this block of code starting from new ShakeDetector:

mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mShakeDetector = new ShakeDetector(new OnShakeListener() {

        @Override
        public void onShake() {
            handleNewAnswer();

        }
    });

}

I tried changing the Java settings in the project properties like someone suggested, but no luck.

The intellisense gives me two options: Change constructor 'ShakeDetector(OnShakeListener)' to 'ShakeDetector(OnShakeListener)' OR Create constructor 'ShakeDetector(OnShakeListener)'

Please tell me there's an easy fix...

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

I'm so sorry I missed this post! If you are still having trouble, reply in here with your full code for MainActivity and we'll try to get you sorted.

Hi Ben! In the end I managed to figure it out after all. :).