Back to project page caddisfly-app-camera.
The source code is released under:
GNU General Public License
If you think the Android project caddisfly-app-camera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) TernUp Research Labs/*from w w w.j a va2s .c om*/ * * This file is part of Caddisfly * * Caddisfly is free software: you can redistribute it and modify it under the terms of * the GNU Affero General Public License (AGPL) as published by the Free Software Foundation, * either version 3 of the License or any later version. * * Caddisfly is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Affero General Public License included below for more details. * * The full license text can also be seen at <http://www.gnu.org/licenses/agpl.html>. */ package com.ternup.caddisfly.util; import com.ternup.caddisfly.R; import android.content.Context; import android.location.Location; /** * Defines app-wide constants and utilities */ public final class LocationUtils { /* * Define a request code to send to Google Play services * This code is returned in Activity.onActivityResult */ public final static int CONNECTION_FAILURE_RESOLUTION_REQUEST = 9000; /* * Constants for location update parameters */ // Milliseconds per second public static final int MILLISECONDS_PER_SECOND = 1000; // The update interval public static final int UPDATE_INTERVAL_IN_SECONDS = 5; // Update interval in milliseconds public static final long UPDATE_INTERVAL_IN_MILLISECONDS = MILLISECONDS_PER_SECOND * UPDATE_INTERVAL_IN_SECONDS; // A fast interval ceiling public static final int FAST_CEILING_IN_SECONDS = 1; // A fast ceiling of update intervals, used when the app is visible public static final long FAST_INTERVAL_CEILING_IN_MILLISECONDS = MILLISECONDS_PER_SECOND * FAST_CEILING_IN_SECONDS; // Create an empty string for initializing strings public static final String EMPTY_STRING = ""; /** * Get the latitude and longitude from the Location object returned by * Location Services. * * @param currentLocation A Location object containing the current location * @return The latitude and longitude of the current location, or null if no * location is available. */ public static String getLatLng(Context context, Location currentLocation) { // If the location is valid if (currentLocation != null) { // Return the latitude and longitude as strings return context.getString( R.string.latitude_longitude, currentLocation.getLatitude(), currentLocation.getLongitude()); } else { // Otherwise, return the empty string return EMPTY_STRING; } } }