Search in sources :

Example 41 with Location

use of android.location.Location in project androidquery by androidquery.

the class LocationAjaxCallback method getBestLocation.

private Location getBestLocation() {
    Location loc1 = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    Location loc2 = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (loc2 == null)
        return loc1;
    if (loc1 == null)
        return loc2;
    if (loc1.getTime() > loc2.getTime()) {
        return loc1;
    } else {
        return loc2;
    }
}
Also used : Location(android.location.Location)

Example 42 with Location

use of android.location.Location in project simplefacebook by androidquery.

the class PostActivity method handleCheckin.

private void handleCheckin(Intent data) {
    Location loc = (Location) data.getParcelableExtra("location");
    Place place = (Place) data.getSerializableExtra("place");
    AQUtility.debug(loc, item);
    if (loc != null && place != null) {
        clear();
        this.location = loc;
        this.place = place;
        attachPlace(place);
        refreshButtons();
    }
}
Also used : Place(com.androidquery.simplefeed.data.Place) Location(android.location.Location)

Example 43 with Location

use of android.location.Location in project androidquery by androidquery.

the class AQueryLocationTest method testLocationIter3Acc10000.

public void testLocationIter3Acc10000() {
    LocationAjaxCallback cb = new LocationAjaxCallback() {

        private int n;

        @Override
        public void callback(String url, Location loc, AjaxStatus status) {
            n++;
            AQUtility.debug(n);
            AQUtility.debug(loc);
            assertNotNull(loc);
            if (n == 3) {
                assertEquals("gps", loc.getProvider());
            }
        }
    };
    cb.timeout(30 * 1000).accuracy(10000).iteration(3).tolerance(-1);
    cb.async(getActivity());
    waitAsync(5000);
}
Also used : LocationAjaxCallback(com.androidquery.callback.LocationAjaxCallback) AjaxStatus(com.androidquery.callback.AjaxStatus) Location(android.location.Location)

Example 44 with Location

use of android.location.Location in project androidquery by androidquery.

the class AQueryLocationTest method testLocationIter2AccFail.

public void testLocationIter2AccFail() {
    LocationAjaxCallback cb = new LocationAjaxCallback() {

        private int n;

        @Override
        public void callback(String url, Location loc, AjaxStatus status) {
            n++;
            AQUtility.debug(n);
            AQUtility.debug(loc);
            if (n == 2) {
                assertNull(loc);
                assertEquals(AjaxStatus.TRANSFORM_ERROR, status.getCode());
            } else if (n < 2) {
                assertNotNull(loc);
            } else {
                assertTrue(false);
            }
        }
    };
    cb.timeout(5 * 1000).accuracy(-1).iteration(2).tolerance(-1);
    cb.async(getActivity());
    waitAsync(6000);
}
Also used : LocationAjaxCallback(com.androidquery.callback.LocationAjaxCallback) AjaxStatus(com.androidquery.callback.AjaxStatus) Location(android.location.Location)

Example 45 with Location

use of android.location.Location in project androidquery by androidquery.

the class AQueryLocationTest method testLocationIter1Acc10000.

public void testLocationIter1Acc10000() {
    LocationAjaxCallback cb = new LocationAjaxCallback() {

        private int n;

        @Override
        public void callback(String url, Location loc, AjaxStatus status) {
            n++;
            AQUtility.debug(n);
            AQUtility.debug(loc);
            assertNotNull(loc);
            if (n == 1) {
                assertEquals("gps", loc.getProvider());
            }
        }
    };
    cb.timeout(5 * 1000).accuracy(10000).iteration(1).tolerance(-1);
    cb.async(getActivity());
    waitAsync(5000);
}
Also used : LocationAjaxCallback(com.androidquery.callback.LocationAjaxCallback) AjaxStatus(com.androidquery.callback.AjaxStatus) Location(android.location.Location)

Aggregations

Location (android.location.Location)284 Bundle (android.os.Bundle)48 LocationListener (android.location.LocationListener)36 LocationManager (android.location.LocationManager)31 ArrayList (java.util.ArrayList)29 Criteria (android.location.Criteria)19 LocationProviderInterface (com.android.server.location.LocationProviderInterface)18 GsmCellLocation (android.telephony.gsm.GsmCellLocation)17 BluetoothAdapter (android.bluetooth.BluetoothAdapter)12 BroadcastReceiver (android.content.BroadcastReceiver)12 Handler (android.os.Handler)10 MockProvider (com.android.server.location.MockProvider)9 Timer (java.util.Timer)8 Test (org.junit.Test)8 PendingIntent (android.app.PendingIntent)7 IOException (java.io.IOException)7 LocationProviderProxy (com.android.server.location.LocationProviderProxy)6 HashMap (java.util.HashMap)6 List (java.util.List)6 Map (java.util.Map)6