Example usage for android.hardware Sensor TYPE_ALL

List of usage examples for android.hardware Sensor TYPE_ALL

Introduction

In this page you can find the example usage for android.hardware Sensor TYPE_ALL.

Prototype

int TYPE_ALL

To view the source code for android.hardware Sensor TYPE_ALL.

Click Source Link

Document

A constant describing all sensor types.

Usage

From source file:org.uguess.android.sysinfo.SiragonManager.java

private int getSensorState() {
    SensorManager sm = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);

    if (sm != null) {
        List<Sensor> ss = sm.getSensorList(Sensor.TYPE_ALL);

        int c = 0;

        if (ss != null) {
            c = ss.size();//from w w  w .j  a v a  2  s  . c  o  m
        }

        return c;
    }

    return -1;
}

From source file:com.cellbots.logger.LoggerActivity.java

/**
 * Prints all the sensors to LogCat.//from   w w  w  .  j  a  va  2 s  . co  m
 */
private void printSensors() {
    List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
    for (int i = 0; i < sensors.size(); i++) {
        Sensor s = sensors.get(i);
        Log.d("DEBUG", s.getName());
    }
    Log.d("DEBUG", "Also logging wifi. You're welcome.");
}

From source file:com.davidmascharka.lips.TrackerActivity.java

@Override
public void onResume() {
    super.onResume();

    File root = Environment.getExternalStorageDirectory();
    File dir = new File(root.getAbsolutePath() + "/indoor_localization");
    dir.mkdirs();/*ww w  .  jav a 2s  .com*/
    file = new File(dir, "livetest_" + building + ".txt");
    valuesFile = new File(dir, "livetest_" + building + "_values.txt");
    try {
        outputStream = new FileOutputStream(file, true);
        valuesOutputStream = new FileOutputStream(valuesFile, true);
        writer = new PrintWriter(outputStream);
        valuesWriter = new PrintWriter(valuesOutputStream);
    } catch (Exception e) {
        e.printStackTrace();
    }

    // Set building textview to the building the user has selected
    //TextView buildingText = (TextView) findViewById(R.id.text_building);
    //buildingText.setText("Building: " + building);

    // Set room size textview to the room size the user has selected
    //TextView roomSizeText = (TextView) findViewById(R.id.text_room_size);
    //roomSizeText.setText("Room size: " + roomWidth + " x " + roomLength);

    // Set grid options
    GridView grid = (GridView) findViewById(R.id.tracker_gridView);
    //grid.setGridSize(roomWidth, roomLength);
    grid.setGridSize(102, 64);
    grid.setCatchInput(false);
    //grid.setDisplayMap(displayMap);

    // Register to get sensor updates from all the available sensors
    sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL);
    for (Sensor sensor : sensorList) {
        sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_FASTEST);
    }

    // Enable wifi if it is disabled
    if (!wifiManager.isWifiEnabled()) {
        Toast.makeText(this, "WiFi not enabled. Enabling...", Toast.LENGTH_SHORT).show();
        wifiManager.setWifiEnabled(true);
    }

    // Request location updates from gps and the network
    //@author Mahesh Gaya added permission if-statment
    if (ActivityCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        Log.i(TAG, "Permissions have NOT been granted. Requesting permissions.");
        requestMyPermissions();
    } else {
        Log.i(TAG, "Permissions have already been granted. Getting location from GPS and Network");
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
    }

    registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));

    wifiManager.startScan();
    Toast.makeText(this, "Initiated scan", Toast.LENGTH_SHORT).show();

    xText = (TextView) findViewById(R.id.tracker_text_xcoord);
    yText = (TextView) findViewById(R.id.tracker_text_ycoord);
}