Skip to content

Instantly share code, notes, and snippets.

@saurabhfg
Created December 6, 2018 06:01
Show Gist options
  • Save saurabhfg/67f578d1aba3dabdca4d134b72d88e75 to your computer and use it in GitHub Desktop.
Save saurabhfg/67f578d1aba3dabdca4d134b72d88e75 to your computer and use it in GitHub Desktop.
Seismic.java
class MainActivity extends Activity implements ShakeDetector.Listener {
ShakeDetector sd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_home);
sd = new ShakeDetector(this);
}
@Override
protected void onResume() {
super.onResume();
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
sd.start(sensorManager);
}
@Override
protected void onPause() {
super.onPause();
sd.stop();
}
@Override
public void hearShake() {
showMessage("Shake!!!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment