BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-20-2007, 09:03 AM   #1
alzzz
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8800
PIN: N/A
Carrier: o2
Posts: 25
Question GPS Programming Question

Please Login to Remove!

Hi all,

I'm attempting to write a program that uses an 8800's internal gps to return the current location and plot a path to a different location on BBmaps.

My first question is whether its a necessity to use the GPSSettings class(net.rim.device.api.gps) to set port and ip?

or

can i go straight into the lbs classes?(javax.microedtion.location)

next when i want to use the BBmaps is the MapView class the only one i can use?

thanks,
Alex
Offline  
Old 11-20-2007, 10:51 AM   #2
MikeLit
New Member
 
Join Date: Nov 2007
Model: 7100t
PIN: N/A
Carrier: at&t
Posts: 1
Default

1. Buy hammer at local hardware store
2. Place Blackberry on table
3. Let gravity take its course
Offline  
Old 11-20-2007, 12:02 PM   #3
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

To get the location the most simple way is to implement LocationListener.
To use the maps you have to build a location document.
I made myself a static utility class to do this (and invoke the maps app).

I'll post you a sample. I use an own location-class but you can easily replace them with QualifiedCoordinates.

be warned though that the internal gps of the 8800 is quite bad (maybe that was the message the man with the hammer tried to deliver)

Code:
	public static void showRoute(Location location1, Location location2, String error){
		String route = "<lbs>" + "<getRoute>" +
		"<location y='" +
		(int)(location1.getLatitude()*100000)+
		"' x='"
		+(int)(location1.getLongitude()*100000)+
		"' />"+
		"<location y='" +
		(int)(location2.getLatitude()*100000)+
		"' x='"
		+(int)(location2.getLongitude()*100000)+
		"' />"+
		"</getRoute>" +
		"<location-document>"
			+"<location y='"
			+(int)(location1.getLatitude()*100000)
			+"' x='"
			+(int)(location1.getLongitude()*100000)
			+"' label='"
			+location1.getCity()
			+"' description='"
			+"' zoom='10'/></location-document>"
			+"</lbs>";
		try{
		Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(
				MapsArguments.ARG_LOCATION_DOCUMENT, route));
	} catch (Exception e) {
		handleExeption(error);
	}
	}
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 11-21-2007, 08:36 AM   #4
alzzz
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8800
PIN: N/A
Carrier: o2
Posts: 25
Default

Thanks simon - that will be very handy when i get to that section

For now though i'm having a problem getting even the most basic lbs code to work on a simulator!

I'm just trying to get the coordinates returned but keep recieving a null value for location from the locationProvider

I'm assuming this shouldnt be a problem in the simulator? - i am setting a gps location in it!

my code is:

Code:
import javax.microedition.location.*;

public class gpstest {

   public static void main(String[] args){


       Criteria cr = new Criteria();
       cr.setHorizontalAccuracy(500);
       Coordinates c = null;
       Location loc;
       LocationProvider lp;
       System.out.println("1");
       try{
       lp = LocationProvider.getInstance(cr);

       //get location
       System.out.println("2");
       loc = lp.getLocation(60);
       System.out.println("3");
       c = loc.getQualifiedCoordinates();
   }
       catch(Exception e){}
       if(c != null ) {
   // Use coordinate information
   System.out.println("4");
           double lat = c.getLatitude();
           double lon = c.getLongitude();
       }
}
   gpstest() {    }
}

thanks
Alex
Offline  
Old 11-21-2007, 08:40 AM   #5
penguin3107
BlackBerry God
 
penguin3107's Avatar
 
Join Date: Jan 2005
Model: iOS 5
Carrier: VZW
Posts: 11,701
Default

Quote:
Originally Posted by MikeLit View Post
1. Buy hammer at local hardware store
2. Place Blackberry on table
3. Let gravity take its course
There's definitely some missing steps in this process.

I assume you intend to smash the BlackBerry with the hammer?
Step 1 and 2 sort of make sense but then the process goes way off course.

Step 3 is just insane. What would gravity have to do with the process?
The table counteracts gravity and is preventing the device from falling to the floor. I suppose you could use the hammer to push the BlackBerry off the edge, but I don't think that's where you were going with your instructions.

If your intention is actually to smash the device with the hammer... then you really aren't using gravity at all, and there's no need to let "gravity take its course."
You'd be applying force to the hammer with your arm in the direction of the BlackBerry causing the hammer to strike to the device. Again, gravity isn't a real factor here, until the little bits of broken device fly off the table and land on the floor. At that point, gravity is "taking its course" however, the damage has already been done so it's not really relevant .

I dunno... maybe I'm being a little too critical.
__________________
BCSA
BES 5.0.3 MR4 :-: Exchange 2007 SP3 RU3
http://port3101.org

Last edited by penguin3107; 11-21-2007 at 08:46 AM..
Offline  
Old 11-21-2007, 08:58 AM   #6
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

switch "gps-receiver in range" on the simulator.
now go to "GPS location" and define two (or more) locations.
create a route using these locations and "run" the route.
the location provider should now provide you with simulated coordinates


regarding the gravity: if you hold a heavy enough hammer high enough gravity should be sufficient.
kids: don't try this with the simulator!
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 11-21-2007, 09:26 AM   #7
alzzz
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8800
PIN: N/A
Carrier: o2
Posts: 25
Default

thanks for that again simon - but now i'm getting an
illegalstateException:no application Instance
at the
Code:
lp=LocationProvider.getInstance(cr)
line
Offline  
Old 12-03-2007, 05:26 PM   #8
nath04
New Member
 
Join Date: Dec 2007
Model: none
PIN: N/A
Carrier: none
Posts: 1
Default

Quote:
Originally Posted by alzzz View Post
thanks for that again simon - but now i'm getting an
illegalstateException:no application Instance
at the
Code:
lp=LocationProvider.getInstance(cr)
line
I'm also stuck at this stage.. is anyone able to provide a solution or work around?
Offline  
Old 12-04-2007, 06:19 AM   #9
sgallego
Knows Where the Search Button Is
 
Join Date: Dec 2007
Location: Spain
Model: 8100
Carrier: Vodafone
Posts: 26
Default Maps Arguments

Hi !!

I'm so interested in the XML format string that Simon has passed as MapsArguments...
Anyone knows where is any documentation about that XML schema?? What others options can I send to Maps Arguments??

Thanks.


Quote:
Originally Posted by simon.hain View Post
To get the location the most simple way is to implement LocationListener.
To use the maps you have to build a location document.
I made myself a static utility class to do this (and invoke the maps app).

I'll post you a sample. I use an own location-class but you can easily replace them with QualifiedCoordinates.

be warned though that the internal gps of the 8800 is quite bad (maybe that was the message the man with the hammer tried to deliver)

Code:
	public static void showRoute(Location location1, Location location2, String error){
		String route = "<lbs>" + "<getRoute>" +
		"<location y='" +
		(int)(location1.getLatitude()*100000)+
		"' x='"
		+(int)(location1.getLongitude()*100000)+
		"' />"+
		"<location y='" +
		(int)(location2.getLatitude()*100000)+
		"' x='"
		+(int)(location2.getLongitude()*100000)+
		"' />"+
		"</getRoute>" +
		"<location-document>"
			+"<location y='"
			+(int)(location1.getLatitude()*100000)
			+"' x='"
			+(int)(location1.getLongitude()*100000)
			+"' label='"
			+location1.getCity()
			+"' description='"
			+"' zoom='10'/></location-document>"
			+"</lbs>";
		try{
		Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(
				MapsArguments.ARG_LOCATION_DOCUMENT, route));
	} catch (Exception e) {
		handleExeption(error);
	}
	}
Offline  
Old 12-04-2007, 06:31 AM   #10
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

GPS_and_BlackBerry_Maps_Development_Guide.pdf covers all the XML stuff. You can mix most of it to get routes with certain points detailed etc

regarding the simulator: if you check 'gps receiver in range' you should get a location provider - providing you with 0/0. To get different coordinates you have to run a route between coordinates
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-05-2007, 03:15 AM   #11
sgallego
Knows Where the Search Button Is
 
Join Date: Dec 2007
Location: Spain
Model: 8100
Carrier: Vodafone
Posts: 26
Default

Thank you very much!!!

I have searched for this PDF for a lot of time!!!
Offline  
Old 12-10-2007, 12:21 PM   #12
alzzz
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8800
PIN: N/A
Carrier: o2
Posts: 25
Default

Did anybody get the original guestion working?

i have tried putting the code onto my blackberry to avoid the emulator confusion but still get a nullpointer exception

Has anybody ever got this working because i am finding millions of similar questions but no answers!!

alex
Offline  
Old 12-11-2007, 03:14 AM   #13
Skipper_Joe
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Default

You get "illegalstateException:no application Instance" because you don't have instance of net.rim.device.api.system.Application.

You can do something like this, for example:
Code:
public class MyApp extends UiApplication
{
    public MyApp()
    {
          new Thread()
          { 
               public void run()
               {
                   // type your JSR--179 code here
               }
          }.start();
    }

    public static void main(String[] args)
    {
        MyApp app = new MyApp();
        app.enterEventDispatcher();
    }
}
For more detailes see JDE javadoc and BlackBerry Developer Guide. Also you can check gpsdemo sample, bundled with JDE.
Offline  
Old 01-05-2008, 09:21 PM   #14
gingko
New Member
 
Join Date: Jan 2008
Model: 8830
PIN: N/A
Carrier: Sprint
Posts: 1
Question

Quote:
Originally Posted by simon.hain View Post
switch "gps-receiver in range" on the simulator.
now go to "GPS location" and define two (or more) locations.
create a route using these locations and "run" the route.
the location provider should now provide you with simulated coordinates
This might be a stupid question. How exactly can one switch on "gps-receiver in range" on the simulator? I can see "GPS Location" under "simulate" menu and I can create locations and routes. I can play/stop play route. However there are no impact on the simulator, I am still getting null from "getQualifiedCoordinates()" call. I assume that "gps-receiver in range" switch has been turned on.

TIA for any help!
Offline  
Old 01-05-2008, 09:56 PM   #15
holden
BlackBerry Extraordinaire
 
holden's Avatar
 
Join Date: May 2007
Location: Florida Sunshine
Model: 9700
OS: 5.0.0.296
PIN: TOFJAGER
Carrier: Cingular-AT&T-Verizon-Nextel
Posts: 1,046
Default Speed of digital data...

Quote:
Originally Posted by penguin3107 View Post
There's definitely some missing steps in this process.

I assume you intend to smash the BlackBerry with the hammer?
Step 1 and 2 sort of make sense but then the process goes way off course.

Step 3 is just insane. What would gravity have to do with the process?
The table counteracts gravity and is preventing the device from falling to the floor. I suppose you could use the hammer to push the BlackBerry off the edge, but I don't think that's where you were going with your instructions.

If your intention is actually to smash the device with the hammer... then you really aren't using gravity at all, and there's no need to let "gravity take its course."
You'd be applying force to the hammer with your arm in the direction of the BlackBerry causing the hammer to strike to the device. Again, gravity isn't a real factor here, until the little bits of broken device fly off the table and land on the floor. At that point, gravity is "taking its course" however, the damage has already been done so it's not really relevant .

I dunno... maybe I'm being a little too critical.
This is inline with the digital 1's and 0's asumptions. If the 1's are flatter, they will pass through the chip set faster than the 0's as they are bigger... etc. etc....
__________________
hmeister...
nettech
Offline  
Old 01-14-2008, 07:22 AM   #16
alzzz
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8800
PIN: N/A
Carrier: o2
Posts: 25
Default

Quote:
Originally Posted by gingko View Post
This might be a stupid question. How exactly can one switch on "gps-receiver in range" on the simulator? I can see "GPS Location" under "simulate" menu and I can create locations and routes. I can play/stop play route. However there are no impact on the simulator, I am still getting null from "getQualifiedCoordinates()" call. I assume that "gps-receiver in range" switch has been turned on.

TIA for any help!
thats exactly the problem i was experiencing and still havent found a solution to it at the mo - currently put it to the side in order to concentrate on communicating with a server
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


NEW  National Instruments NI 9213 cDAQ Temperature / Thermocouple Input Module picture

NEW National Instruments NI 9213 cDAQ Temperature / Thermocouple Input Module

$1530.00



National Instruments NI-9214 Thermocouple input Module with NI TB-9214 picture

National Instruments NI-9214 Thermocouple input Module with NI TB-9214

$2585.00



NEW Sealed AB 1756-IT6I2 ControlLogix Enhanced Isolated Thermocouple Module  picture

NEW Sealed AB 1756-IT6I2 ControlLogix Enhanced Isolated Thermocouple Module

$759.05



For 1769-IT6 6 Pt Thermocouple Module in Box picture

For 1769-IT6 6 Pt Thermocouple Module in Box

$4199.88



Cooking Performance Group Thermocouple 351302170058 picture

Cooking Performance Group Thermocouple 351302170058

$55.99



9.8ft K Type 50x5mm 500C Probe Thermocouple Temperature Sensor Cable 3 Meters picture

9.8ft K Type 50x5mm 500C Probe Thermocouple Temperature Sensor Cable 3 Meters

$13.48







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