BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-23-2010, 10:38 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Capturing location information is not working inside building

Please Login to Remove!

This application works perfect in the simulator. It also works if the device is put outside the building.
But not working inside the building.

I found that BlackBerryCriteria() constructor sets the GPS mode in the following order: Autonomous, Assisted, Cellsite mode.

But in my case only Autonomous is working. If Autonomous is not available, I need to switch to Assisted or Cellsite mode.

My understanding on GPSInfo.isGPSModeAvailable() is, it only checks whether the mode is supported on blackberry device, right?

I need someone's help to solve this problem.
Here's my code snippets

Code:
public void setNewLocation() {
		Thread t = new Thread(new Runnable() {
			public void run() {
				try {
					BlackBerryCriteria criteria = new BlackBerryCriteria();
				
					criteria.setCostAllowed(true);
					criteria.setPreferredPowerConsumption(BlackBerryCriteria.POWER_USAGE_MEDIUM);
					criteria.setHorizontalAccuracy(BlackBerryCriteria.NO_REQUIREMENT);
					criteria.setVerticalAccuracy(BlackBerryCriteria.NO_REQUIREMENT);
					criteria.setGPSRestartInterval(120, 3);

					BlackBerryLocationProvider locProvider = (BlackBerryLocationProvider) 								LocationProvider.getInstance(criteria);
					if(locProvider!=null){
					locProvider.setLocationListener(new MyLocationListener(),
							30, 15, 15);
					}

				} catch (Exception e) {
					addErrorQueue(e.getMessage());
				}
			}
		});
		t.start();
	}
And the listener code is
Code:
public class MyLocationListener implements LocationListener {
	public void locationUpdated(LocationProvider provider, Location myLocation) {
		if (myLocation instanceof BlackBerryLocation) {
				if (myLocation.isValid()) {
					BlackBerryLocation location = (BlackBerryLocation) myLocation;
					try {
						QualifiedCoordinates qc = location.getQualifiedCoordinates();
						double lat = qc.getLatitude();
						double lon = qc.getLongitude(); 
						float heading = location.getCourse();
						float speed = location.getSpeed(); 
						int satellites = location.getSatelliteCount();
						addLocationQueue(new MyLocation(........));

					} catch (Exception ex) {
						addErrorQueue(ex.getMessage());
					}
				}
				else
				{
					addErrorQueue("Invalid location");
				}
		} 
	}

	public void providerStateChanged(LocationProvider provider, int newState) {
		
	}
}

Last edited by romah : 11-23-2010 at 10:40 AM.
Offline  
Old 11-23-2010, 11:18 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Capturing location information is not working inside building

I tried with this code and it works perfect for the first time inside the building also. That means it captures the location for the first time.
But it doesnot work for another time interval. It throws timeout exception, then terminates the process. What am I doing wrong?

Code:
if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_CELLSITE)) {
	criteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_CELLSITE);			
             criteria.setFailoverMode(GPSInfo.GPS_MODE_ASSIST, 2, 60);
	criteria.setSubsequentMode(GPSInfo.GPS_MODE_ASSIST);
	} else if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASSIST)) {
		criteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_ASSIST);
		criteria.setFailoverMode(GPSInfo.GPS_MODE_AUTONOMOUS,1, 30);
		criteria.setSubsequentMode(GPSInfo.GPS_MODE_AUTONOMOUS);
	           } else if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_AUTONOMOUS)) {
			criteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_AUTONOMOUS);
			criteria.setFailoverMode(GPSInfo.GPS_MODE_AUTONOMOUS,1, 30);
			criteria.setSubsequentMode(GPSInfo.GPS_MODE_AUTONOMOUS);
			}

Last edited by romah : 11-23-2010 at 11:22 AM.
Offline  
Old 11-29-2010, 10:55 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Capturing location information is not working inside building

Please someone help me to capture the location information inside the building and also handle the exception when timeout.

Here is the message:
"Uncaught exception: Application My_GPS_Test (223) is not responding: process terminated."

And the code:
Code:
try {
	BlackBerryCriteria criteria = new BlackBerryCriteria();
				
	BlackBerryCriteria criteria = new BlackBerryCriteria(gpsMode);

	criteria.setPreferredResponseTime(BlackBerryCriteria.NO_REQUIREMENT);
	criteria.setCostAllowed(true);

	if (gpsMode == GPSInfo.GPS_MODE_AUTONOMOUS) {
		criteria.setCostAllowed(false);
	} else if (gpsMode == GPSInfo.GPS_MODE_ASSIST) {
		criteria.setPreferredPowerConsumption(BlackBerryCriteria.POWER_USAGE_MEDIUM);
		} else {
			criteria.setPreferredPowerConsumption(BlackBerryCriteria.POWER_USAGE_LOW);
			}

	try {
		locationProvider = LocationProvider.getInstance(criteria);
		if (locationProvider != null) {
			locationProvider.setLocationListener(
				new MyLocationListener(), -1, -1, -1);
			}
				
	} catch (LocationException ex) {
		addErrorQueue(ex.getMessage());
		}

} catch(UnsupportedOperationException e) {
	addErrorQueue(e.getMessage());
}

Last edited by romah : 11-29-2010 at 10:57 AM.
Offline  
Old 11-29-2010, 01:27 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: Capturing location information is not working inside building

This error: Uncaught exception: Application My_GPS_Test (223) is not responding: process terminated

...indicates that you are performing a blocking operation in the event thread. Blocking operations (like GPS or communications) should be performed in a separate worker thread. If you block the event thread, the system will terminate your process (with this error) as soon as the event queue fills up.
Offline  
Old 11-29-2010, 01:55 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Capturing location information is not working inside building

I am running this setLocation() method in separate thread once it is called. My timer thread only checks the errorQueue and locationQueue. If there are items in queues, the timer thread sends them to the database server.

Dougsg38p, which one will be the blocking operation in my code above? This exception only pop-ups when the device is inside the building. Otherwise, it works perfect outside the building. i.e., application works perfect if the device is line-of-sight with satellites.
Offline  
Old 11-29-2010, 05:09 PM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: Capturing location information is not working inside building

The longer you block the event thread, the more likely that you will get an overflow and hence the exception. This would why you get away with it in the case where the GPS works quickly, but it fails where the GPS hangs for a long time.

Obviously, you are blocking somewhere. I don't see this in the last code snippet, but it doesn't really show me enough to make a determination.
Offline  
Old 12-01-2010, 03:22 PM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Capturing location information is not working inside building

If there is no satellite coverage (i.e. inside a building), how to switch the mode into Cellsite (i.e., cell triangulation).
And if there is satellite coverage comes back (i.e., outside the building), how to switch back to autonomous mode.

I tried like this but not worked.

Code:
criteria.setMode(GPSInfo.GPS_MODE_AUTONOMOUS);
criteria.setFailoverMode(GPSInfo.GPS_MODE_AUTONOMOUS, 1, 30);
criteria.setSubsequentMode(GPSInfo.GPS_MODE_CELLSITE);
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Capturing location information is not working inside building
Thread Thread Starter Forum Replies Last Post
Signal Location utility for Blackberry BETA... RemyJ Aftermarket Software 425 10-17-2010 11:44 AM
Location Based Services (LBS) otherwise known as GPS Policies TargetIT BES Admin Corner 5 01-12-2009 07:54 AM
Unite! Help Guide Sith_Apprentice BlackBerry Unite 17 12-25-2008 01:08 PM
Sync Error....What could it be? kurrupt_1 General 8300 Series Discussion - Curve 7 11-22-2007 06:41 PM
7100I Big HELP whoknowswhat General Legacy Device Discussion 1 10-23-2005 03:45 PM





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.