Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 174
Registered: ‎09-04-2011
My Device: Bold
My Carrier: at&t

Failed to get the GPS location on Verizon Curve 8530

Hi, expert,

 

right now, our code is not able to retrieve the GPS location at a customer device which is VZ curve 8530 (it is working at the devices we tested so far). Our code would use unassisted GPS  and then it would use cell site. Both are failed to retrieve the GPS location, here are our code for GPS location retrieve:

 

function getGPSLoc(int method)
{
	try
	{
		criteria = new Criteria();
		if (method == UNASSISTED_GPS)
		{
			Logger.infoStatic(loggerName, "Getting location using method: UNASSISTED_GPS");
			criteria.setVerticalAccuracy(50);
			criteria.setHorizontalAccuracy(50);
			criteria.setCostAllowed(true);
			criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);
		}
		else if (method == ASSISTED_GPS)
		{
			Logger.infoStatic(loggerName, "Getting location using method: ASSISTED_GPS");
			criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
			criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
			criteria.setCostAllowed(true);
			criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_MEDIUM);
		}
		else if (method == CELL_SITE)
		{
			Logger.infoStatic(loggerName, "Getting location using method: CELL_SITE");
			criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
			criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
			criteria.setCostAllowed(true);
			criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
		}

		LocationProvider provider = LocationProvider.getInstance(criteria);
		Location location = provider.getLocation(30);// 30 seconds
														// timeout
		
		//to-do 
		//MaaSLocationListener.getInstance().registerListener(provider);
		QualifiedCoordinates qualifiedCoordinates = location.getQualifiedCoordinates();
		m_longitude = qualifiedCoordinates.getLongitude();
		m_latitude = qualifiedCoordinates.getLatitude();

		int method = location.getLocationMethod();
		if ((method & Location.MTA_ASSISTED) == Location.MTA_ASSISTED)
		{
			locationDetectionMethod = "Assisted GPS";
		}
		if ((method & Location.MTA_UNASSISTED) == Location.MTA_UNASSISTED)
		{
			locationDetectionMethod = "Unassisted GPS";
		}
		if ((method & Location.MTE_CELLID) == Location.MTE_CELLID)
		{
			locationDetectionMethod = "Cell Site";
		}
		releaseLock();

	}
	catch (LocationException e)
	{
		Logger.errorStatic(loggerName, "LocationException: " + e.getMessage());
		releaseLock();
	}
	catch (InterruptedException e)
	{
		Logger.errorStatic(loggerName, "InterruptedException: " + e.getMessage());
		releaseLock();
	}

	catch (SecurityException e)
	{
		Logger.errorStatic(loggerName, "SecurityException: " + e.getMessage());
		releaseLock();
	}
	catch (Exception e)
	{
		Logger.errorStatic(loggerName, "Exception while collecting location details " + e.getMessage());
		releaseLock();
	}
}

 

We would call this function first with method as UNASSISTED_GPS. If it is failed, we would call again with CELL_SITE. We didn't use the ASSISTED_GPS method here.

 

However our code is not able to retrieve the GPS location with both UNASSISTED_GPS and CELL_SITE. From this link, http://forums.crackberry.com/gps-mapping-f41/8530-gps-368991/

it looks like the VZ disabled GPS for third party software, however we should be able to get it from CELL_SITE, however we are not able to get it and we get some exception back, however the getMessage call for the exception return null, so we don't really know what exception we get.

 

Maybe ASSISTED_GPS woudl help, unfortunately right now, we don't try that on our code. Any insights on this would be highly appreciated.

 

 

 

Highlighted
Trusted Contributor
Posts: 174
Registered: ‎09-04-2011
My Device: Bold
My Carrier: at&t

Re: Failed to get the GPS location on Verizon Curve 8530

[ Edited ]

after some testing on VZ curve 8530 device, we found out that we could get it working if we modify the following code to set cost allowed as false:

		else if (method == CELL_SITE)
		{
			Logger.infoStatic(loggerName, "Getting location using method: CELL_SITE");
			criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
			criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
			criteria.setCostAllowed(true);
			criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
		}

 

It is a little weird since I would think that setCostAllowed as true would mean that either cost could be incured or not incured. Just wonder if anyone knows more about how Location Provider works here. We would like to understand more to have some generic code to handle all cases.