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 Build a Simple Android App (retired 2014) Shaking Things Up The Activity Lifecycle

Akshay Shivpuri
Akshay Shivpuri
2,917 Points

Error while creating OnResume() and OnPause()

I'm getting the following errors

//Starts here-->
Multiple markers at this line - Syntax error, insert "EnumBody" to complete BlockStatement - Syntax error, insert "enum Identifier" to complete EnumHeaderName - Syntax error on token "void", @ expected

What to fix?

I hope christopherbasinger can help here. :D

Akshay Shivpuri
Akshay Shivpuri
2,917 Points

Here's the code

...

            @Override
    public void onResume(){
        super.onResume();
        mSensorManager.registerListener(mShakeDetector, mAccelerometer,
                SensorManager.SENSOR_DELAY_UI);
    }

    @Override
    public void onPause(){
        super.onPause();
        mSensorManager.unregisterListener(mShakeDetector);
    }

...

Error: The error is coming on both the methods.

... Multiple markers at this line - Syntax error, insert "EnumBody" to complete BlockStatement - Syntax error, insert "enum Identifier" to complete EnumHeaderName - Syntax error on token "void", @ expected ...

Marcus Vieira
Marcus Vieira
7,877 Points

Hi Akshay!

Would you mind posting the entire code here ?

Thanks :)

1 Answer

Akshay Shivpuri
Akshay Shivpuri
2,917 Points

Well I figured out the answer. By mistake, I'd put the above two functions within "OnCreate()" method.