android–GPS– 在跑步和行走时获得距离,时间

android–GPS– 在跑步和行走时获得距离,时间,第1张

概述我有一种情况需要使用GPS技术.当人走路时,我需要找到两点之间的距离.当该人开始行走时,他将点击“开始”按钮,当他停止时,他点击停止按钮在此之后它应该告诉他1.时间2.在Kms旅行.3.从哪里到哪里(地名)例如:a到b我需要谷歌地图吗?我在这里看到了link的代码来获取当前位置,它给

我有一种情况需要使用GPS技术.

当人走路时,我需要找到两点之间的距离.

当该人开始行走时,他将点击“开始”按钮,当他停止时,他点击停止按钮

在此之后它应该告诉他

1.时间
2.在Kms旅行.
3.从哪里到哪里(地名)例如:a到b

我需要谷歌地图吗?

我在这里看到了link的代码来获取当前位置,它给出了纬度经度.

请帮忙解决这个问题

**

编辑:

**

这是我正在使用的代码

private EditText editTextShowLocation;    private @R_301_5554@ @R_301_5554@GetLocation;    private Progressbar progress;    private LocationManager locManager;    private LocationListener locListener = new MyLocationListener();    private boolean gps_enabled = false;    private boolean network_enabled = false;    /** Called when the activity is first created. */    @OverrIDe    public voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.main);        editTextShowLocation = (EditText) findVIEwByID(R.ID.editTextShowLocation);        progress = (Progressbar) findVIEwByID(R.ID.progressbar1);        progress.setVisibility(VIEw.GONE);        @R_301_5554@GetLocation = (@R_301_5554@) findVIEwByID(R.ID.@R_301_5554@GetLocation);        @R_301_5554@GetLocation.setonClickListener(this);        locManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);    }    @OverrIDe    public voID onClick(VIEw v) {        progress.setVisibility(VIEw.VISIBLE);        // exceptions will be thrown if provIDer is not permitted.        try {            gps_enabled = locManager.isProvIDerEnabled(LocationManager.GPS_PROVIDER);        } catch (Exception ex) {        }        try {            network_enabled = locManager.isProvIDerEnabled(LocationManager.NETWORK_PROVIDER);        } catch (Exception ex) {        }        // don't start Listeners if no provIDer is enabled        if (!gps_enabled && !network_enabled) {            AlertDialog.Builder builder = new Builder(this);            builder.setTitle("Attention!");            builder.setMessage("Sorry, location is not determined. Please enable location provIDers");            builder.setPositive@R_301_5554@("OK", this);            builder.setNeutral@R_301_5554@("Cancel", this);            builder.create().show();            progress.setVisibility(VIEw.GONE);        }        if (gps_enabled) {            locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);        }        if (network_enabled) {            locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);        }    }    class MyLocationListener implements LocationListener {        @OverrIDe        public voID onLocationChanged(Location location) {            if (location != null) {                // This needs to stop getting the location data and save the battery power.                locManager.removeUpdates(locListener);                 String londitude = "Londitude: " + location.getLongitude();                String latitude = "Latitude: " + location.getLatitude();                String altitiude = "Altitiude: " + location.getAltitude();                String accuracy = "Accuracy: " + location.getAccuracy();                String time = "Time: " + location.getTime();                editTextShowLocation.setText(londitude + "\n" + latitude + "\n" + altitiude + "\n" + accuracy + "\n" + time);                progress.setVisibility(VIEw.GONE);            }         }        @OverrIDe        public voID onProvIDerDisabled(String provIDer) {            // Todo auto-generated method stub        }        @OverrIDe        public voID onProvIDerEnabled(String provIDer) {            // Todo auto-generated method stub        }        @OverrIDe        public voID onStatusChanged(String provIDer, int status, Bundle extras) {            // Todo auto-generated method stub        }    }    @OverrIDe    public voID onClick(DialogInterface dialog, int which) {        if(which == DialogInterface.@R_301_5554@_NEUTRAL){            editTextShowLocation.setText("Sorry, location is not determined. To fix this please enable location provIDers");        }else if (which == DialogInterface.@R_301_5554@_POSITIVE) {            startActivity(new Intent(androID.provIDer.Settings.ACTION_LOCATION_SOURCE_SETTINGS));        }    }

它显示我从仿真器控件进入的Logitude Latitude.

在这里我手动输入经度和纬度的细节
通过转到window-> showvIEw-> other->模拟器控件进行模拟器中的测试
但我需要的是我将有两个edittext,我输入地名(A)和(B)

它应该给我的距离

请帮忙

解决方法:

尝试使用Google distance Matrix API

https://developers.google.com/maps/documentation/distancematrix/

总结

以上是内存溢出为你收集整理的android – GPS – 在跑步和行走时获得距离,时间全部内容,希望文章能够帮你解决android – GPS – 在跑步和行走时获得距离,时间所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1099800.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存