Domanda

I am porting an Android app to BlackBerry 10 OS using the Java Runtime support. My app is working fine on Android devices currently, but I cannot get location updates from the BlackBerry device.

My manifest requests the COARSE_LOCATION permission:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

In my code, I request location updates from an Activity:

LocationListener listener = new LocationListener()
{
    public void onLocationChanged(Location location)
    {
        Log.v(TAG, "onLocationChanged");
        // Code to save returned location...
    }
    public void onStatusChanged(String provider, int status, Bundle extras) {}
    public void onProviderEnabled(String provider)  {}
    public void onProviderDisabled(String provider) {}
};
LocationManager lm = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, listener);
Log.v(TAG, "Registered network location listeners");

I see the "registered listeners" log line printed from the device, but I never see "onLocationChanged" get logged, and my code that saves the supplied location is never invoked.

In some other place, I try to fetch the last known location:

LocationManager lm = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
Location lastLocation = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

lastLocation is always null.

To be clear, this code works fine on Android devices and is well tested.

Also relevant: the BB10 device reports that my app has the GPS location permission, but not the regular location permission, even though my manifest requests COARSE_LOCATION only. Might be related?

UPDATE:

I have an open ticket with BlackBerry Support. They say "This is a known issue it is in the process of being fixed with internal development."

È stato utile?

Soluzione 2

The problem was in the BlackBerry Android runtime. It has been fixed in OS 10.1.

The support ticket is here (now closed): https://www.blackberry.com/jira/browse/BBTEN-999

See this forum thread also: http://supportforums.blackberry.com/t5/Android-Runtime-Development/Can-not-fetch-location-using-network-provider/m-p/2424553#M5040

Altri suggerimenti

Do you have read geo location permission set in your bar descriptor xml file ?

http://developer.blackberry.com/air/documentation/bb10/r_barfile_dtd_ref_permission.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top