Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.hardware.SensorManager;

public class Main {
    public static boolean isSensorAvailable(Context ctx, int type_sensor) {
        boolean isSensorAvailable = false;
        SensorManager sensorManger = null;

        sensorManger = (SensorManager) ctx.getSystemService(ctx.SENSOR_SERVICE);

        if (sensorManger.getDefaultSensor(type_sensor) != null) {
            isSensorAvailable = true;
        }

        return isSensorAvailable;
    }
}