交通应用软件Android的GPS应用 [英] android gps app for traffic application

查看:124
本文介绍了交通应用软件Android的GPS应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前完成学习Android开发的基础知识,我努力学习,使智能手机在Android的GPS应用我的交通系统项目。不会因此还没有做复杂的codeS不错。请指教一些资源或教程,这将极大地帮助我,使这个应用程序。
    - 应用程序将发送GPS位置(纬度和放大器;经度和时间)通过手机短信,每10秒一次它接近一个特定的路段(可以像路0.5公里长度)
    - 如果手机通过特定路段将停止发送其位置

I've currently finished learning the basics of android development and am trying to learn to make an android gps app in smartphones for my traffic system project. Not so very good yet in doing complicated codes. Please advise some resources or tutorials which will greatly help me to make this app. - the app will send gps locations( lat & longitude and time ) via sms every 10 seconds once it approach a specific road section ( can be like 0.5 km length of road) - if the phone passed that specific road section it will stop sending its locations

推荐答案

为什么要使用SMS服务发送的位置?尝试使用web服务。

Why are you using the sms service to send the location? try using the webservice.

要实现这个程序,你必须使用的LocationManager和LocationListener的库。
您可以通过创建一个GPS听力课实施LocationListener的,像下面

To implement this app you has to use the LocationManager and LocationListener libraries. You can start by creating a gps listening class implementing the LocationListener, like the one shown below

public class CTLocationListener implements LocationListener{




@Override
public void onLocationChanged(Location location) {
    Log.w("LOCATION CHANGED", ""+location);



    if(location != null) {

        Constants.LATTITUDE = location.getLatitude();
        Constants.LONGITUDE = location.getLongitude();
        Constants.kAccuracy = location.getAccuracy();
        Constants.ALTITUDE_VALUE = location.getAltitude();
    }


}

@Override
public void onProviderDisabled(String provider) {
    Log.i("PROVIDER", "DISABLED:"+provider);


}

@Override
public void onProviderEnabled(String provider) {
    Log.i("PROVIDER", "ENABLED:"+provider);

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    Log.i("EXTRAS", ""+extras);
    Log.i("Provider status", ""+status);
}

}

在这里,我存储在常量文件更新的位置。启动定期检查地点sheduler并开始发送邮件,如果他们符合您需要的位置。

Here I'm storing the updated locations on the Constants file. Start a sheduler that checks the locations periodically and start sending messages if they match your required locations.

要触发GPS可以使用

LocationListener locationListener = new CTLocationListener(); 
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1.0f, locationListener);

您所需要的调度是一个TimerTask。这可被实现为

The scheduler you need is a timertask. This can be implemented as

public class showAccuracy extends TimerTask {

    @Override
    public void run() {

        ghandler.post(new Runnable() {

            @Override
            public void run() {
                if((Constants.Latitude == yourlatitude) && .....) {

}
                }
            });
        }

} } }); }

}

这篇关于交通应用软件Android的GPS应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆