package com.cn.mygooglemapdemo;
import java.util.Iterator;
import android.content.Context;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
/**
* GPS助手类
*
* @author yateng
*
*/
public class GPSLocationHelper {
public Location location;
public LocationManager gpsLocationManager;
public MyLocationListener mLocationListener = new MyLocationListener();
public static GPSLocationHelper gpsLocationHelper = new GPSLocationHelper();
public static final String tag = "GPSLocationHelper";
public GPSLocationHelper() {
}
/**
* 获取GPSLocationHelper实例
*/
public static GPSLocationHelper getIntance() {
return gpsLocationHelper;
}
/**
* 如果GPS是开启状态,则开始使用定位
*
* @param context
* @param limitTime
* GPS定位一次限制时间(秒),超过时间停止定位
*/
public void startGPSService(Context context, int limitTime) {
// 获取LocationManager实例
gpsLocationManager = (LocationManager) context
.getSystemService(Context.LOCATION_SERVICE);
// GPS在手机里面没有被开启,直接返回
if (!(gpsLocationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER)))
return;
// 位置变化监听,默认0秒一次,距离0米以上
gpsLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0, 0, new MyLocationListener());
}
/**
* 位置变化监听类,获取到位置时将调用onLocationChanged
*/
public class MyLocationListener implements LocationListener {
public void onLocationChanged(Location location) {
// 此函数被运行,表明获取到位置
GPSLocationHelper.this.location = location;
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
/**
* 停止获取GPS位置
*/
public void stopGPSService() {
if (gpsLocationManager != null)
gpsLocationManager.removeUpdates(mLocationListener);
}
/**
* 得到位置信息
*
* @return
*/
public Location getGPSLocation() {
return location;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
android安卓绝对可以获取GPS经纬度的google map demo。使用谷歌api,不需要网络,可以直接获取经纬度,获取经纬度写到一个类中,直接调用start,关闭使用stop。 注意要在室外使用! 打开应用,马上开始获取地址,多次点击 第一个按钮: 获取gps经纬度, 如果程序获取到位置,会弹出经纬度
资源推荐
资源详情
资源评论
收起资源包目录
绝对可以获取GPS经纬度的google map demo.zip (30个子文件)
绝对可以获取GPS经纬度的google map demo
MyGoogleMapDemo
.project 851B
bin
MyGoogleMapDemo.apk 15KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
resources.ap_ 11KB
classes
com
cn
mygooglemapdemo
R$string.class 439B
GPSLocationHelper$MyLocationListener.class 1KB
Main$1.class 2KB
R$layout.class 406B
GPSLocationHelper.class 2KB
R$drawable.class 419B
R.class 559B
Main$2.class 894B
Main.class 1KB
R$attr.class 352B
R$id.class 428B
classes.dex 5KB
proguard.cfg 1KB
AndroidManifest.xml 835B
src
com
cn
mygooglemapdemo
GPSLocationHelper.java 2KB
Main.java 1KB
project.properties 376B
res
values
strings.xml 196B
layout
main.xml 637B
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 3KB
.classpath 364B
gen
com
cn
mygooglemapdemo
R.java 800B
assets
共 30 条
- 1
icewst
- 粉丝: 42
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页