Created
January 16, 2020 16:27
-
-
Save panchicore/7d3780a5bbe38de16a5f786e8ecff954 to your computer and use it in GitHub Desktop.
Device shake detection implemented in Kotlin, powered by Seismic.
This file contains hidden or 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
import android.content.Context | |
import android.hardware.SensorManager | |
import android.os.Bundle | |
import androidx.appcompat.app.AppCompatActivity | |
import com.squareup.seismic.ShakeDetector | |
import kotlinx.android.synthetic.main.activity_main.* | |
class MainActivity : AppCompatActivity(), ShakeDetector.Listener { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager | |
val sd = ShakeDetector(this) | |
sd.start(sensorManager) | |
} | |
override fun hearShake() { | |
// shaked. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment