Example usage for android.hardware GeomagneticField getDeclination

List of usage examples for android.hardware GeomagneticField getDeclination

Introduction

In this page you can find the example usage for android.hardware GeomagneticField getDeclination.

Prototype

public float getDeclination() 

Source Link

Usage

From source file:Main.java

/**
 * Returns declination in degrees at given location
 * /* w ww . j  a va2s . co m*/
 * @param location
 * @return Declination in degrees
 */
public static float getDeclinationAt(float latitude, float longitude, float altitude) {
    GeomagneticField gf = new GeomagneticField(latitude, longitude, altitude, System.currentTimeMillis());
    return gf.getDeclination();
}

From source file:com.nextgis.mobile.forms.CompassFragment.java

public static float getDeclination(Location location, long timestamp) {

    if (location == null) {
        return 0;
    }/*from w  w  w. ja  v a 2s. c  o  m*/
    GeomagneticField field = new GeomagneticField((float) location.getLatitude(),
            (float) location.getLongitude(), (float) location.getAltitude(), timestamp);

    return field.getDeclination();
}

From source file:com.nextgis.maplibui.fragment.CompassFragment.java

public static float getDeclination(Location location, long timestamp) {
    if (location == null)
        return 0;

    GeomagneticField field = new GeomagneticField((float) location.getLatitude(),
            (float) location.getLongitude(), (float) location.getAltitude(), timestamp);

    return field.getDeclination();
}

From source file:com.javadog.cgeowear.cgeoWear.java

/**
 * Interprets watch compass if user has requested that feature.
 *///w ww  . j  av  a2s .co  m
@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        gravity = event.values.clone();
    } else if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
        geomagnetic = event.values.clone(); //TODO: Some watches don't let me access the compass correctly yet.
    }

    if (gravity != null && geomagnetic != null) {
        float[] R = new float[9];
        float[] I = new float[9];

        boolean success = SensorManager.getRotationMatrix(R, I, gravity, geomagnetic);
        if (success) {
            float[] orientation = new float[3];
            SensorManager.getOrientation(R, orientation);
            float azimuth = (float) Math.toDegrees(orientation[0]);

            if (currentLocation != null) {
                float smoothedLatitude = smoothSensorValues(oldLatitude, (float) currentLocation.getLatitude(),
                        1 / 3f);
                float smoothedLongitude = smoothSensorValues(oldLongitude,
                        (float) currentLocation.getLongitude(), 1 / 3f);
                float smoothedAltitude = smoothSensorValues(oldAltitude, (float) currentLocation.getAltitude(),
                        1 / 3f);

                GeomagneticField geomagneticField = new GeomagneticField(smoothedLatitude, smoothedLongitude,
                        smoothedAltitude, System.currentTimeMillis());
                azimuth += geomagneticField.getDeclination();

                float bearing = currentLocation.bearingTo(geocacheLocation);

                direction = smoothSensorValues(oldDirection, -(azimuth - bearing), 1 / 5f);

                //Set old values to current values (for smoothing)
                oldDirection = direction;
                oldLatitude = smoothedLatitude;
                oldLongitude = smoothedLongitude;
                oldAltitude = smoothedAltitude;

                //Display direction on compass if update interval has passed
                long currentTime = System.currentTimeMillis();
                if ((currentTime - prevTime) > DIRECTION_UPDATE_SPEED) {
                    rotateCompass(direction);
                    prevTime = currentTime;
                }
            }
        }
    }
}

From source file:com.javadog.cgeowear.WearService.java

/**
 * Handles compass rotation./* w w  w  . j a  va  2  s .co  m*/
 */
@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        gravity = event.values.clone();
    } else if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
        geomagnetic = event.values.clone();
    }

    if (gravity != null && geomagnetic != null) {
        float[] R = new float[9];
        float[] I = new float[9];

        boolean success = SensorManager.getRotationMatrix(R, I, gravity, geomagnetic);
        if (success) {
            float[] orientation = new float[3];
            SensorManager.getOrientation(R, orientation);
            float azimuth = (float) Math.toDegrees(orientation[0]);
            float pitch = (float) Math.toDegrees(orientation[1]);

            if (currentLocation != null) {
                float smoothedLatitude = smoothSensorValues(oldLatitude, (float) currentLocation.getLatitude(),
                        1 / 3f);
                float smoothedLongitude = smoothSensorValues(oldLongitude,
                        (float) currentLocation.getLongitude(), 1 / 3f);
                float smoothedAltitude = smoothSensorValues(oldAltitude, (float) currentLocation.getAltitude(),
                        1 / 3f);

                GeomagneticField geomagneticField = new GeomagneticField(smoothedLatitude, smoothedLongitude,
                        smoothedAltitude, System.currentTimeMillis());
                azimuth += geomagneticField.getDeclination();

                float bearing = currentLocation.bearingTo(geocacheLocation);

                float direction = smoothSensorValues(oldDirection, -(azimuth - bearing), 1 / 5f);

                //If the user puts the phone in his/her pocket upside-down, invert the compass
                if (pitch > 0) {
                    direction += 180f;
                }

                //Set old values to current values (for smoothing)
                oldDirection = direction;
                oldLatitude = smoothedLatitude;
                oldLongitude = smoothedLongitude;
                oldAltitude = smoothedAltitude;

                //Send direction update to Android Wear if update interval has passed
                long currentTime = System.currentTimeMillis();
                if ((currentTime - prevTime) > DIRECTION_UPDATE_SPEED) {
                    wearInterface.sendDirectionUpdate(direction);
                    prevTime = currentTime;
                }
            }
        }
    }
}

From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationMapFragment.java

public void onSensorChanged(SensorEvent event) {

    if (event.sensor == mAccelerometer) {
        accValues.put(event.values);/* w  w  w .  j av  a2s.  c o  m*/
        // System.arraycopy(event.values, 0, mLastAccelerometer, 0, event.values.length);
        mLastAccelerometerSet = true;
    } else if (event.sensor == mMagnetometer) {
        if (Math.sqrt(event.values[0] * event.values[0] + event.values[1] * event.values[1]
                + event.values[2] * event.values[2]) > SensorManager.MAGNETIC_FIELD_EARTH_MAX * 1.5) {
            return;
        }
        if (event.values.length < 3) {
            return;
        }
        magValues.put(event.values);
        // System.arraycopy(event.values, 0, mLastMagnetometer, 0, event.values.length);
        mLastMagnetometerSet = true;
    }

    if (mLastAccelerometerSet && mLastMagnetometerSet) {
        SensorManager.getRotationMatrix(mR, null, accValues.get(), magValues.get());
        // SensorManager.remapCoordinateSystem(mR, SensorManager.AXIS_X,
        // SensorManager.AXIS_Z, remapMatrix);
        SensorManager.getOrientation(mR, mOrientation); // remapMatrx
        if (SMLocationManager.getInstance().hasValidLocation()) {
            Location currentLoc = SMLocationManager.getInstance().getLastValidLocation();
            float azimuth = -(float) Math.toDegrees(mOrientation[0]);
            final GeomagneticField geoField = new GeomagneticField(
                    Double.valueOf(currentLoc.getLatitude()).floatValue(),
                    Double.valueOf(currentLoc.getLongitude()).floatValue(),
                    Double.valueOf(currentLoc.getAltitude()).floatValue(), System.currentTimeMillis());
            azimuth += geoField.getDeclination(); // converts magnetic north
            // into true north
            // LOG.d("azimuth = " + azimuth);
            compassOrientation = azimuth;// - bearing;
            // if (Math.abs(locationOverlay.compassOrientation - compassOrientation) > 5) {
            // locationOverlay.compassOrientation = compassOrientation;
            // mapView.invalidate();
            // }
            // }
            // }
        }
    }
}

From source file:gov.nasa.arc.geocam.geocam.GeoCamService.java

void postProcessLocation(Uri uri) {
    final String[] projection = new String[] { MediaStore.Images.ImageColumns._ID,
            MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.LATITUDE,
            MediaStore.Images.ImageColumns.LONGITUDE, MediaStore.Images.ImageColumns.DESCRIPTION,
            MediaStore.Images.ImageColumns.SIZE, };

    try {//from  w w w .  jav  a  2s .com
        Cursor cur = getContentResolver().query(uri, projection, null, null, null);
        cur.moveToFirst();

        long dateTakenMillis = cur.getLong(cur.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN));
        String imageData = cur.getString(cur.getColumnIndex(MediaStore.Images.ImageColumns.DESCRIPTION));
        cur.close();

        List<Location> points = mGpsLog.getBoundingLocations(dateTakenMillis, 1);
        if (points.size() == 2) {
            Location before = points.get(0);
            Location after = points.get(1);
            double lat, lon, alt;

            long beforeDiff = dateTakenMillis - before.getTime();
            long afterDiff = after.getTime() - dateTakenMillis;
            long diff = beforeDiff + afterDiff;

            if (diff < GeoCamMobile.PHOTO_BRACKET_INTERVAL_MSECS) {
                // best case -- not too much time lag between bracketing positions. interpolate.
                double a = ((double) beforeDiff) / diff;
                lat = before.getLatitude() + a * (after.getLatitude() - before.getLatitude());
                lon = before.getLongitude() + a * (after.getLongitude() - before.getLongitude());
                alt = before.getAltitude() + a * (after.getAltitude() - before.getLongitude());
            } else if (beforeDiff < GeoCamMobile.PHOTO_BRACKET_THRESHOLD_MSECS
                    || afterDiff < GeoCamMobile.PHOTO_BRACKET_THRESHOLD_MSECS) {
                // one of the two points is close enough in time to the photo capture time. use its position.
                if (beforeDiff < afterDiff) {
                    lat = before.getLatitude();
                    lon = before.getLongitude();
                    alt = before.getAltitude();
                } else {
                    lat = after.getLatitude();
                    lon = after.getLongitude();
                    alt = after.getAltitude();
                }
            } else {
                // otherwise, we don't have any usable position data
                lat = 0.0;
                lon = 0.0;
                alt = 0.0;
            }

            // Fix the geomagnetic declination if we have all of our info
            if (!(lat == 0.0 && lon == 0.0 && alt == 0.0)) {
                GeomagneticField field = new GeomagneticField((float) lat, (float) lon, (float) alt,
                        dateTakenMillis);
                float declination = field.getDeclination();

                try {
                    JSONObject dataObj = new JSONObject(imageData);

                    double[] angles = GeoCamMobile.rpyUnSerialize(dataObj.getString("rpy"));
                    angles[2] += declination;
                    Log.d(GeoCamMobile.DEBUG_ID,
                            "Fixed heading. Declination: " + declination + " New heading: " + angles[2]);

                    dataObj.put("rpy", GeoCamMobile.rpySerialize(angles[0], angles[1], angles[2]));
                    dataObj.put("yawRef", GeoCamMobile.YAW_TRUE);

                    imageData = dataObj.toString();
                } catch (JSONException e) {
                    Log.e(GeoCamMobile.DEBUG_ID, "Error decoding/encoding for geomagnetic stuff" + e);
                }
            }

            ContentValues values = new ContentValues(2);
            values.put(MediaStore.Images.ImageColumns.LATITUDE, lat);
            values.put(MediaStore.Images.ImageColumns.LONGITUDE, lon);
            values.put(MediaStore.Images.ImageColumns.DESCRIPTION, imageData);
            getContentResolver().update(uri, values, null, null);
        }
    } catch (CursorIndexOutOfBoundsException e) {

    }
}

From source file:org.mixare.MixViewActivity.java

/**
 * Part of Android LifeCycle that gets called when "MixViewActivity" resumes.
 * <br/>/*from  w  w w. java  2  s.c o m*/
 * 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.dragon4.owo.ar_trace.ARCore.MixView.java

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

    try {/*  w w  w. jav  a2  s  .c o m*/
        this.mWakeLock.acquire(); // ?? ?

        killOnError(); // ?  ?
        mixContext.mixView = this; // ??  
        dataView.doStart(); // ?? 
        dataView.clearEvents(); // ? ?

        double angleX, angleY; // ? x, y

        /*? ?  ? */
        angleX = Math.toRadians(-90);
        m1.set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX), 0f,
                (float) Math.sin(angleX), (float) Math.cos(angleX));

        angleX = Math.toRadians(-90);
        angleY = Math.toRadians(-90);
        m2.set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX), 0f,
                (float) Math.sin(angleX), (float) Math.cos(angleX));
        m3.set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f, (float) -Math.sin(angleY),
                0f, (float) Math.cos(angleY));

        m4.toIdentity();

        for (int i = 0; i < histR.length; i++) {
            histR[i] = new Matrix();
        }
        /*   */

        //  ? 
        sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);

        // ?  ?
        // ?? 
        sensors = sensorMgr.getSensorList(Sensor.TYPE_ACCELEROMETER);
        if (sensors.size() > 0) {
            sensorGrav = sensors.get(0);
        }

        // ? 
        sensors = sensorMgr.getSensorList(Sensor.TYPE_MAGNETIC_FIELD);
        if (sensors.size() > 0) {
            sensorMag = sensors.get(0);
        }
        //// TODO: 2016-06-01
        if (sensors.size() > 0) {
            sensors = sensorMgr_ori.getSensorList(Sensor.TYPE_ORIENTATION);
            orientationSensor = sensors.get(0);
        }
        //  ??  ? ? ? ?
        sensorMgr.registerListener(this, sensorGrav, SENSOR_DELAY_GAME);
        sensorMgr.registerListener(this, sensorMag, SENSOR_DELAY_GAME);

        if (orientationSensor != null) {
            sensorMgr_ori.registerListener(this, orientationSensor, sensorMgr_ori.SENSOR_DELAY_GAME);
        }

        try {
            // ?? (Criteria)
            // http://developer.android.com/reference/android/location/Criteria.html
            Criteria c = new Criteria();

            // ? 
            c.setAccuracy(Criteria.ACCURACY_FINE);
            //c.setBearingRequired(true);

            // ?  
            locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            // ?? ? ?  ? . 2 , 3 
            locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 4, this);

            // ?? ? ,   
            String bestP = locationMgr.getBestProvider(c, true);
            isGpsEnabled = locationMgr.isProviderEnabled(bestP);

            // gps, ? ? ?   
            Location hardFix = new Location("reverseGeocoded");

            try {
                //  ? gps, ??     
                Location gps = locationMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                Location network = locationMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

                //  ?  ?   
                //  gps > ? > 
                if (gps != null)
                    mixContext.curLoc = gps;
                else if (network != null)
                    mixContext.curLoc = network;
                else
                    mixContext.curLoc = hardFix;

            } catch (Exception ex2) { //  ? 
                ex2.printStackTrace(); //  
                mixContext.curLoc = hardFix; //   
            }
            // ? ?  ??  
            mixContext.setLocationAtLastDownload(mixContext.curLoc);

            // ?? .   ?   
            GeomagneticField gmf = new GeomagneticField((float) mixContext.curLoc.getLatitude(),
                    (float) mixContext.curLoc.getLongitude(), (float) mixContext.curLoc.getAltitude(),
                    System.currentTimeMillis());

            // ??   
            angleY = Math.toRadians(-gmf.getDeclination());
            m4.set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f,
                    (float) -Math.sin(angleY), 0f, (float) Math.cos(angleY));
            mixContext.declination = gmf.getDeclination();
        } catch (Exception ex) {
            Log.d("mixare", "GPS Initialize Error", ex); //  ? 
        }
        //  ? 
        downloadThread = new Thread(mixContext.downloadManager);
        downloadThread.start();

    } catch (Exception ex) {
        doError(ex); // ? 

        try {
            // ???  
            if (sensorMgr != null) {
                sensorMgr.unregisterListener(this, sensorGrav);
                sensorMgr.unregisterListener(this, sensorMag);
                sensorMgr = null;
            }
            //  ??   
            if (locationMgr != null) {
                locationMgr.removeUpdates(this);
                locationMgr = null;
            }
            // ??  ?? 
            if (mixContext != null) {
                if (mixContext.downloadManager != null)
                    mixContext.downloadManager.stop();
            }
        } catch (Exception ignore) {
        }
    }

    //  ?? 
    // ??   ? ( ?? ) ?    
    if (dataView.isFrozen() && searchNotificationTxt == null) {
        searchNotificationTxt = new TextView(this);
        searchNotificationTxt.setWidth(dWindow.getWidth());
        searchNotificationTxt.setPadding(10, 2, 0, 0);
        searchNotificationTxt.setBackgroundColor(Color.DKGRAY);
        searchNotificationTxt.setTextColor(Color.WHITE);

        searchNotificationTxt.setOnTouchListener(this);
        addContentView(searchNotificationTxt,
                new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    } else if (!dataView.isFrozen() && searchNotificationTxt != null) {
        searchNotificationTxt.setVisibility(View.GONE);
        searchNotificationTxt = null;
    }
}

From source file:com.androzic.Androzic.java

public double getDeclination(double lat, double lon) {
    GeomagneticField mag = new GeomagneticField((float) lat, (float) lon, 0.0f, System.currentTimeMillis());
    return mag.getDeclination();
}