Accelerometer (Shake Events) Example with Service Android.
Hello Friends, This tutorial is about get shake event when you are not in Application or any specific activity. With the help of Service we can get Shake Event out of activity. First of We will create class which extends Service and Implements SensorEventListener. 1. Class MyService.java import android.app.Notification ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.app.Service ; import android.content.Context ; import android.content.Intent ; import android.hardware.Sensor ; import android.hardware.SensorEvent ; import android.hardware.SensorEventListener ; import android.hardware.SensorManager ; import android.os.Handler ; import android.os.IBinder ; import android.support.v4.app.NotificationCompat ; import com.ammy.shakeevent.R ; public class MyService extends Service implements SensorEventListener { private SensorManager mSensorManager ; private Sensor mAccelerometer ; ...