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 trialRicky Sparks
22,249 Pointswhats wrong with my java code?
package com.example;
import android.os.Bundle; import android.view.View; import android.hardware.Sensor; import android.hardware.SensorManager;
public class MainActivity extends Activity {
public static String aString;
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private ShakeDetector mShakeDetector;
public void onCreate(Bundle savedInstanceState) {
super.onCreate ( savedInstanceState);
setContentView(R.layout.activity_main);
aString = "This variable is set AFTER the 'otherString' variable in Activity";
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mShakeDetector = new ShakeDetector();
}
public void onPause() {
super.onPause();
unregisterListener(ShakeDetector );
}
public void onResume() {
super.onResume();
mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
}
}
Ben Junya
12,365 PointsHey Ricky,
It's really difficult for me to help you out unless I know exactly what's happening. Is the program crashing? Is it doing something it's not supposed to do? We don't know.
Also, if you can list your StackTrace from Logcat, I would be able to help you out more.
Ricky Sparks
22,249 PointsThis is a code challenge.
Ben Junya
12,365 PointsWhat is the challenge asking you to do? What's the instructions or objective?
Ricky Sparks
22,249 PointsRicky Sparks
22,249 Pointsi believe its something in here
public void onPause() { super.onPause(); unregisterListener(ShakeDetector ); }