package com.gs.apidemo;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class SafeMonitorReceiver extends BroadcastReceiver {
    private static final String TAG = "SafeMonitorReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.i(TAG, "onReceive: " + action);
        if ("android.sensor.monitoring.STATE_CHANGED".equals(action)) {
            int type = intent.getIntExtra("sensor_monitoring", 0);
            if (type == 1) {
                Log.i(TAG, "type run");
            } else if (type == 2) {
                Log.i(TAG, "type tilt");
            } else if (type == 3) {
                Log.i(TAG, "type not move");
            }
        }
    }
}
