Example usage for android.hardware Sensor TYPE_ACCELEROMETER

List of usage examples for android.hardware Sensor TYPE_ACCELEROMETER

Introduction

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

Prototype

int TYPE_ACCELEROMETER

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

Click Source Link

Document

A constant describing an accelerometer sensor type.

Usage

From source file:it.flaviomascetti.posture.PostureCheckFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
}

From source file:com.shimi.camera.must.stand.straight.MainActivity.java

@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        updateUiOnMovement(event);
    }
}

From source file:io.authme.sdk.widget.LockPatternView.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public LockPatternView(Context context, AttributeSet attrs) {
    super(context, attrs);
    senSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    senAccelerometer = senSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
    if (senAccelerometer == null) {
        senAccelerometer = senSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    }/*from  ww  w .j a  v a  2s  .  c o  m*/

    senSensorManager.registerListener(this, senAccelerometer, SensorManager.SENSOR_DELAY_GAME);

    sensGyro = senSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);

    if (sensGyro != null) {
        senSensorManager.registerListener(this, sensGyro, SensorManager.SENSOR_DELAY_GAME);
    }

    senMagnetometer = senSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);

    if (senMagnetometer != null) {
        senSensorManager.registerListener(this, senMagnetometer, SensorManager.SENSOR_DELAY_GAME);
    }

    accelList = new ArrayList<>();
    magnetics = new ArrayList<>();
    gyrolist = new ArrayList<>();
    rawXYList = new ArrayList<>();
    velocityList = new ArrayList<>();
    orientationArrayList = new ArrayList<>();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Alp_42447968_LockPatternView);

    final String aspect = a.getString(R.styleable.Alp_42447968_LockPatternView_alp_42447968_aspect);

    if ("square".equals(aspect)) {
        mAspect = ASPECT_SQUARE;
    } else if ("lock_width".equals(aspect)) {
        mAspect = ASPECT_LOCK_WIDTH;
    } else if ("lock_height".equals(aspect)) {
        mAspect = ASPECT_LOCK_HEIGHT;
    } else {
        mAspect = ASPECT_SQUARE;
    }

    setClickable(true);

    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);

    mRegularColor = getResources().getColor(
            ResourceUtils.resolveAttribute(getContext(), R.attr.alp_42447968_color_lock_pattern_view_regular));
    mErrorColor = getResources().getColor(
            ResourceUtils.resolveAttribute(getContext(), R.attr.alp_42447968_color_lock_pattern_view_error));
    mSuccessColor = getResources().getColor(
            ResourceUtils.resolveAttribute(getContext(), R.attr.alp_42447968_color_lock_pattern_view_success));

    mRegularColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_regularColor,
            mRegularColor);
    mErrorColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_errorColor, mErrorColor);
    mSuccessColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_successColor,
            mSuccessColor);

    int pathColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_pathColor, mRegularColor);
    mPathPaint.setColor(pathColor);

    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);

    mPathWidth = getResources().getDimensionPixelSize(R.dimen.alp_42447968_lock_pattern_dot_line_width);
    mPathPaint.setStrokeWidth(mPathWidth);

    mDotSize = getResources().getDimensionPixelSize(R.dimen.alp_42447968_lock_pattern_dot_size);
    mDotSizeActivated = getResources()
            .getDimensionPixelSize(R.dimen.alp_42447968_lock_pattern_dot_size_activated);

    mPaint.setAntiAlias(true);
    mPaint.setDither(true);

    mCellStates = new CellState[MATRIX_WIDTH][MATRIX_WIDTH];
    for (int i = 0; i < MATRIX_WIDTH; i++) {
        for (int j = 0; j < MATRIX_WIDTH; j++) {
            mCellStates[i][j] = new CellState();
            mCellStates[i][j].size = mDotSize;
        }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !isInEditMode()) {
        mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_slow_in);
        mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.linear_out_slow_in);
    } // if
}

From source file:com.google.android.apps.santatracker.doodles.tilt.SwimmingFragment.java

@Override
public void onSensorChanged(SensorEvent event) {
    if (event.values == null || model == null) {
        return;/*  w  w w  .  ja v  a  2s  .  c o m*/
    }
    int sensorType = event.sensor.getType();
    if (sensorType == Sensor.TYPE_ACCELEROMETER) {
        float[] adjustedEventValues = AndroidUtils.getAdjustedAccelerometerValues(displayRotation,
                event.values);
        float x = -adjustedEventValues[0] * ACCELEROMETER_SCALE;
        float y = -adjustedEventValues[1] * ACCELEROMETER_SCALE;
        // Accelerometer input is very noisy, so we filter it using a (simple) low-pass filter.
        float weight = 0.1f;
        model.tilt.x = model.tilt.x + weight * (x - model.tilt.x);
        model.tilt.y = model.tilt.y + weight * (y - model.tilt.y);
    }
}

From source file:org.deviceconnect.android.deviceplugin.host.HostDeviceService.java

/**
 * Device Orientation Profile<br>/*ww  w . j  a  v  a 2 s  .  c  om*/
 * ?.
 * 
 * @param response ?
 * @param deviceId ?ID
 * @param sessionKey 
 */
public void registerDeviceOrientationEvent(final Intent response, final String deviceId,
        final String sessionKey) {

    mDeviceId = deviceId;
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);

    if (sensors.size() > 0) {
        Sensor sensor = sensors.get(0);
        mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
    }

    sensors = mSensorManager.getSensorList(Sensor.TYPE_GYROSCOPE);

    if (sensors.size() > 0) {
        Sensor sensor = sensors.get(0);
        mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
    }

    response.putExtra(DConnectMessage.EXTRA_RESULT, DConnectMessage.RESULT_OK);
    response.putExtra(DConnectMessage.EXTRA_VALUE, "Register OnDeviceOrientation event");
    sendBroadcast(response);
}

From source file:net.line2soft.preambul.views.SlippyMapActivity.java

/**
 * Init map's overlays (compass, buttons, ...), attach listener.
 * You can launch map on normal or edit mode (to pick a position).
 * @param addFavorite If true, edit mode (to add favorite), if false normal mode
 *//*from  w w w.  j  a va2 s.  c o  m*/
private void initMap(boolean addFavorite) {
    if (addFavorite == false) {
        //Launch map in normal mode
        findViewById(R.id.list_item).setVisibility(View.VISIBLE);
        findViewById(R.id.drawer).setVisibility(View.VISIBLE);

        //Add listener on excursions button
        ImageButton btExcursionsImg = (ImageButton) findViewById(R.id.imageButton1);
        btExcursionsImg.setOnClickListener(listener);
        btExcursionsImg.setVisibility(View.VISIBLE);
        findViewById(R.id.excursionButton).setVisibility(View.VISIBLE);
        ((ImageButton) findViewById(R.id.imageRight)).setOnClickListener(listener);
        ((ImageButton) findViewById(R.id.imageLeft)).setOnClickListener(listener);
        ((ImageButton) findViewById(R.id.favoritesButton)).setOnClickListener(listener);

        //Display POIs on map
        try {
            PointOfInterest[] pois = MapController.getInstance(this).getCurrentLocation().getPOIs(this);
            Drawable icon = null;
            OverlayItem item = null;
            boolean displayPoiType = true;
            for (PointOfInterest poi : pois) {
                displayPoiType = PreferenceManager.getDefaultSharedPreferences(this)
                        .getBoolean("type" + poi.getType().getId(), true);
                if (displayPoiType) {
                    icon = (poi.getType().getIcon() == null) ? poi.getType().getCategory().getIcon()
                            : poi.getType().getIcon();
                    item = new OverlayItem(poi.getPoint(), poi.getName(), poi.getComment(),
                            BalloonItemizedOverlay.boundLeftCenter(icon));
                    overlayPoiItemMarker.addItem(item, poi);
                }
            }
        } catch (Exception e) {
            displayInfo(getString(R.string.message_map_poi_load_error));
            e.printStackTrace();
        }

        //Display favorites on map
        try {
            HashMap<String, NamedPoint> favorites = MapController.getInstance(this).getCurrentLocation()
                    .getNamedFavorites(this);
            Drawable icon = getResources().getDrawable(R.drawable.marker_favorite);
            OverlayItem item = null;
            for (NamedPoint favPoint : favorites.values()) {
                item = new OverlayItem(favPoint.getPoint(), favPoint.getName(), favPoint.getComment(),
                        BalloonItemizedOverlay.boundLeftCenter(icon));
                overlayPoiItemMarker.addItem(item, favPoint);
            }
        } catch (IOException e) {
            displayInfo(getString(R.string.message_map_favorite_load_error));
            e.printStackTrace();
        }

        //Display excursions and instruction on map
        int pathToDisplay = MapController.getInstance(this).getPathToDisplay();
        displayExcursion(pathToDisplay);
        int instructionToDisplay = MapController.getInstance(this).getInstructionToDisplay() - 1;
        //Set instruction, only if > 0 because if instruction=0, was set when displaying excursion
        if (instructionToDisplay > 0) {
            setNavigationInstructionToDisplay(instructionToDisplay);
        }
        //Display of the bookmarksButton
        boolean displaybookmarksButton = PreferenceManager.getDefaultSharedPreferences(this)
                .getBoolean("displayBookmarksButton", true);
        ImageButton img = (ImageButton) findViewById(R.id.favoritesButton);
        if (displaybookmarksButton) {
            img.setVisibility(View.VISIBLE);
        } else {
            img.setVisibility(View.GONE);
        }
        //Display point
        GeoPoint pointToDisplay = MapController.getInstance(this).getPointToDisplay();
        if (pointToDisplay != null) {
            displayPosition(pointToDisplay.getLatitude(), pointToDisplay.getLongitude());
            MapController.getInstance(this).setPointToDisplay(null);
        }
        //Launch compass
        boolean displayCompass = PreferenceManager.getDefaultSharedPreferences(this)
                .getBoolean("displayCompass", true);
        CompassView cpv = (CompassView) findViewById(R.id.compass);
        CompassView cpvBig = (CompassView) findViewById(R.id.compassBig);
        if (displayCompass) {
            SensorManager mySensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
            Sensor mAccelerometer = mySensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
            Sensor mField = mySensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
            if (mField != null && mAccelerometer != null) {
                mySensorManager.registerListener(listener, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
                mySensorManager.registerListener(listener, mField, SensorManager.SENSOR_DELAY_UI);
                cpv.setOnClickListener(listener);
                if (isCompassAccurate) {
                    cpv.setVisibility(View.VISIBLE);
                } else {
                    displayInfo(getString(R.string.message_compass_not_accurate));
                    cpv.setVisibility(View.GONE);
                }
                cpvBig.setVisibility(View.GONE);
                cpvBig.setOnClickListener(listener);
            } else {
                cpv.setVisibility(View.GONE);
                cpvBig.setVisibility(View.GONE);
            }
        } else {
            cpv.setVisibility(View.GONE);
            cpvBig.setVisibility(View.GONE);
        }

        //Hide validate button
        findViewById(R.id.validatePositionButton).setVisibility(View.GONE);
        findViewById(R.id.imageViewValidate).setVisibility(View.GONE);
        findViewById(R.id.mapPointer).setVisibility(View.GONE);
    } else {
        //Launch map in edit mode, to set coordinates of a favorite
        findViewById(R.id.list_item).setVisibility(View.GONE);
        findViewById(R.id.compass).setVisibility(View.GONE);
        findViewById(R.id.drawer).setVisibility(View.GONE);
        findViewById(R.id.favoritesButton).setVisibility(View.GONE);

        findViewById(R.id.mapPointer).setVisibility(View.VISIBLE);

        //Display validate button and add listener
        findViewById(R.id.validatePositionButton).setVisibility(View.VISIBLE);
        findViewById(R.id.imageViewValidate).setVisibility(View.VISIBLE);
        findViewById(R.id.imageViewValidate).setOnClickListener(listener);

        this.addFavorite = false;
    }
}

From source file:cl.ipp.katbag.fragment.Player.java

public void setSensing(String[] line, int lineNumber) {
    switch (Integer.parseInt(line[3])) {
    case 0://w ww.j  a v  a 2s  .com
        boolean ex = false;
        for (int z = 0; z < touchEventId.size(); z++) {
            if (line[0].contentEquals(String.valueOf(touchEventId.get(z)))) {
                ex = true;
                break;
            }
        }

        if (!ex) {
            int last = -1;
            for (int i = lineNumber + 1; i < develop.size(); i++) {
                String[] it = develop.get(i).split("&&");

                last = i;
                if (Integer.parseInt(line[8]) >= Integer.parseInt(it[8])) {
                    last--;
                    break;
                }
            }

            if ((lineNumber + 1) <= last) {
                touchEventId.add(Integer.valueOf(line[0]));
                touchEventDrawing.add(Integer.valueOf(line[4])); // drawing
                touchEventBgn.add(lineNumber + 1); // begin in
                touchEventLst.add(last); // ends

                final KatbagDrawing drawing = (KatbagDrawing) v.findViewById(Integer.valueOf(line[4]));
                if (drawing != null) {
                    drawing.setOnTouchListener(new OnTouchListener() {

                        @Override
                        public boolean onTouch(View v, MotionEvent event) {
                            switch (event.getAction()) {
                            case MotionEvent.ACTION_DOWN:
                                for (int i = 0; i < touchEventDrawing.size(); i++) {
                                    if (touchEventDrawing.get(i) == drawing.getId()) {
                                        setBranchTreeCondition(touchEventId.get(i), 1);
                                        if (checkTreeCondition(touchEventId.get(i))) {
                                            Log.d("ply", "touchEventDrawing - ini:" + touchEventBgn.get(i)
                                                    + ", last:" + touchEventLst.get(i));
                                            play(touchEventBgn.get(i), touchEventLst.get(i) + 1);
                                            break;
                                        }
                                    }
                                }

                                break;

                            case MotionEvent.ACTION_UP:
                                for (int i = 0; i < touchEventDrawing.size(); i++) {
                                    if (touchEventDrawing.get(i) == drawing.getId()) {
                                        setBranchTreeCondition(touchEventId.get(i), 0);
                                        break;
                                    }
                                }

                                break;
                            }

                            return true;
                        }
                    });

                    Log.d("ply",
                            "setSensing - touchEvent add! count:" + touchEventId.size() + ", drawing:"
                                    + touchEventDrawing.get(touchEventDrawing.size() - 1) + " ini:"
                                    + touchEventBgn.get(touchEventBgn.size() - 1) + " last:"
                                    + touchEventLst.get(touchEventLst.size() - 1));
                }
            }

            if (last > -1)
                if ((last + 1) < develop.size())
                    play((last + 1), develop.size());
        }

        break;

    case 1:
        boolean ex1 = false;
        for (int z = 0; z < shakeId.size(); z++) {
            if (line[0].contentEquals(String.valueOf(shakeId.get(z)))) {
                ex1 = true;
                break;
            }
        }

        if (!ex1) {
            int last1 = -1;
            for (int i = lineNumber + 1; i < develop.size(); i++) {
                String[] it = develop.get(i).split("&&");

                last1 = i;
                if (Integer.parseInt(line[8]) >= Integer.parseInt(it[8])) {
                    last1--;
                    break;
                }
            }

            if ((lineNumber + 1) <= last1) {
                shakeId.add(Integer.valueOf(line[0]));
                shakeBgn.add(lineNumber + 1); // begin in
                shakeLst.add(last1); // ends

                sensorManager = (SensorManager) mainActivity.context.getSystemService(Context.SENSOR_SERVICE);
                accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
                sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST);
                useAccelerometer = true;

                Log.d("ply", "setSensing - shake add! count:" + shakeId.size() + ", ini:"
                        + shakeBgn.get(shakeBgn.size() - 1) + " last:" + shakeLst.get(shakeLst.size() - 1));
            }

            if (last1 > -1)
                if ((last1 + 1) < develop.size())
                    play((last1 + 1), develop.size());
        }

        break;
    }
}

From source file:org.mixare.MixViewActivity.java

/**
 * Part of Android LifeCycle that gets called when "MixViewActivity" resumes.
 * <br/>/*from ww  w .j  a v  a 2 s  . c  om*/
 * Does:
 * - Acquire Screen Lock
 * - Refreshes Data and Downloads
 * - Initiate four Matrixes that holds user's rotation markerRenderer.
 * - Re-register Sensors. {@link android.hardware.SensorManager SensorManager}
 * - Re-register Location Manager. {@link org.mixare.mgr.location.LocationFinder LocationFinder}
 * - Switch on Download Thread. {@link org.mixare.mgr.downloader.DownloadManager DownloadManager}
 * - restart markerRenderer refresh Timer.
 * <br/>
 * {@inheritDoc}
 */
@Override
protected void onResume() {
    super.onResume();
    if (cubeView != null) {
        //mRenderer.start();
        cubeView.onResume();
    }
    mSensorManager.registerListener(cubeView, mOrienation, SensorManager.SENSOR_DELAY_NORMAL);

    try {
        killOnError();
        MixContext.setActualMixViewActivity(this);
        HttpTools.setContext(MixContext.getInstance());

        //repaint(); //repaint when requested
        getMarkerRenderer().doStart();
        getMarkerRenderer().clearEvents();
        MixContext.getInstance().getNotificationManager().setEnabled(true);
        refreshDownload();

        MixContext.getInstance().getDataSourceManager().refreshDataSources();

        float angleX, angleY;

        int marker_orientation = -90;

        int rotation = Compatibility.getRotation(this);

        // display text from left to right and keep it horizontal
        angleX = (float) Math.toRadians(marker_orientation);
        getMixViewData().getM1().set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX), 0f,
                (float) Math.sin(angleX), (float) Math.cos(angleX));
        angleX = (float) Math.toRadians(marker_orientation);
        angleY = (float) Math.toRadians(marker_orientation);
        if (rotation == 1) {
            getMixViewData().getM2().set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX),
                    0f, (float) Math.sin(angleX), (float) Math.cos(angleX));
            getMixViewData().getM3().set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f,
                    (float) -Math.sin(angleY), 0f, (float) Math.cos(angleY));
        } else {
            getMixViewData().getM2().set((float) Math.cos(angleX), 0f, (float) Math.sin(angleX), 0f, 1f, 0f,
                    (float) -Math.sin(angleX), 0f, (float) Math.cos(angleX));
            getMixViewData().getM3().set(1f, 0f, 0f, 0f, (float) Math.cos(angleY), (float) -Math.sin(angleY),
                    0f, (float) Math.sin(angleY), (float) Math.cos(angleY));

        }

        getMixViewData().getM4().toIdentity();

        for (int i = 0; i < getMixViewData().getHistR().length; i++) {
            getMixViewData().getHistR()[i] = new Matrix();
        }

        getMixViewData()
                .addListSensors(getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_ACCELEROMETER));
        if (getMixViewData().getSensor(0).getType() == Sensor.TYPE_ACCELEROMETER) {
            getMixViewData().setSensorGrav(getMixViewData().getSensor(0));
        } //else report error (unsupported hardware)

        getMixViewData()
                .addListSensors(getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_MAGNETIC_FIELD));
        if (getMixViewData().getSensor(1).getType() == Sensor.TYPE_MAGNETIC_FIELD) {
            getMixViewData().setSensorMag(getMixViewData().getSensor(1));
        } //else report error (unsupported hardware)

        if (!getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_GYROSCOPE).isEmpty()) {
            getMixViewData()
                    .addListSensors(getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_GYROSCOPE));
            if (getMixViewData().getSensor(2).getType() == Sensor.TYPE_GYROSCOPE) {
                getMixViewData().setSensorGyro(getMixViewData().getSensor(2));
            }
            getMixViewData().getSensorMgr().registerListener(this, getMixViewData().getSensorGyro(),
                    SENSOR_DELAY_GAME);
        }

        getMixViewData().getSensorMgr().registerListener(this, getMixViewData().getSensorGrav(),
                SENSOR_DELAY_GAME);
        getMixViewData().getSensorMgr().registerListener(this, getMixViewData().getSensorMag(),
                SENSOR_DELAY_GAME);

        try {
            GeomagneticField gmf = MixContext.getInstance().getLocationFinder().getGeomagneticField();
            angleY = (float) Math.toRadians(-gmf.getDeclination());
            getMixViewData().getM4().set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f,
                    (float) -Math.sin(angleY), 0f, (float) Math.cos(angleY));
        } catch (Exception ex) {
            doError(ex, GPS_ERROR);
        }

        if (!isNetworkAvailable()) {
            Log.d(Config.TAG, "no network");
            doError(null, NO_NETWORK_ERROR);
        } else {
            Log.d(Config.TAG, "network");
        }

        MixContext.getInstance().getDownloadManager().switchOn();
        MixContext.getInstance().getLocationFinder().switchOn();
    } catch (Exception ex) {
        doError(ex, GENERAL_ERROR);
        try {
            if (getMixViewData().getSensorMgr() != null) {
                getMixViewData().getSensorMgr().unregisterListener(this, getMixViewData().getSensorGrav());
                getMixViewData().getSensorMgr().unregisterListener(this, getMixViewData().getSensorMag());
                getMixViewData().getSensorMgr().unregisterListener(this, getMixViewData().getSensorGyro());
                getMixViewData().setSensorMgr(null);
            }

            if (MixContext.getInstance() != null) {
                MixContext.getInstance().getLocationFinder().switchOff();
                MixContext.getInstance().getDownloadManager().switchOff();
            }
        } catch (Exception ignore) {
        }
    } finally {
        //This does not conflict with registered sensors (sensorMag, sensorGrav)
        //This is a place holder to API returned listed of sensors, we registered
        //what we need, the rest is unnecessary.
        getMixViewData().clearAllSensors();
    }

    Log.d(Config.TAG, "resume");
    if (getMarkerRenderer() == null) {
        return;
    }
    if (getMarkerRenderer().isFrozen() && getMixViewData().getSearchNotificationTxt() == null) {
        getMixViewData().setSearchNotificationTxt(new TextView(this));
        getMixViewData().getSearchNotificationTxt().setWidth(getPaintScreen().getWidth());
        getMixViewData().getSearchNotificationTxt().setPadding(10, 2, 0, 0);
        getMixViewData().getSearchNotificationTxt().setText(getString(R.string.search_active_1) + " "
                + DataSourceList.getDataSourcesStringList() + getString(R.string.search_active_2));
        ;
        getMixViewData().getSearchNotificationTxt().setBackgroundColor(Color.DKGRAY);
        getMixViewData().getSearchNotificationTxt().setTextColor(Color.WHITE);

        getMixViewData().getSearchNotificationTxt().setOnTouchListener(this);
        addContentView(getMixViewData().getSearchNotificationTxt(),
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    } else if (!getMarkerRenderer().isFrozen() && getMixViewData().getSearchNotificationTxt() != null) {
        getMixViewData().getSearchNotificationTxt().setVisibility(View.GONE);
        getMixViewData().setSearchNotificationTxt(null);
    }
}

From source file:com.mummyding.app.leisure.ui.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_NORMAL);

    if (Settings.needRecreate) {
        Settings.needRecreate = false;/*from  w  ww.ja  v a 2 s  .c om*/
        this.recreate();
    }
}

From source file:nl.vincentketelaars.mexen.activities.RollDice.java

@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        getAccelerometer(event);
    }
}