Created
December 6, 2018 06:01
-
-
Save saurabhfg/67f578d1aba3dabdca4d134b72d88e75 to your computer and use it in GitHub Desktop.
Seismic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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