本代码实现GPS定位,并定时在界面上呈现定位的精度以及在用卫星数量。布局代码如下:LinearLayout xmlns:android=/apk/res/android? ? xmlns:tools=/tools? ? android:layout_width=match_parent? ? android:layout_height=match_parent? ? android:orientation=vertical ? ? TextView? ?? ???android:id=@+id/showtv? ?? ???android:layout_width=fill_parent? ?? ???android:layout_height=wrap_content? ?? ???android:text=GPS经纬度获取服务,每60秒界面更新一次数据,而后台GPS更新服务是每30秒更新一次GPS数据 /? ? LinearLayout? ?? ???android:layout_width=fill_parent? ?? ???android:layout_height=wrap_content? ?? ???android:layout_marginTop=8dp? ?? ???android:gravity=center? ?? ???android:orientation=horizontal ? ?? ???Button? ?? ?? ?? ?android:id=@+id/Startbtn? ?? ?? ?? ?android:layout_width=96dp? ?? ?? ?? ?android:layout_height=48dp? ?? ?? ?? ?android:text=@string/startbtn /? ?? ???Button? ?? ?? ?? ?android:id=@+id/Stopbtn? ?? ?? ?? ?android:layout_width=96dp? ?? ?? ?? ?android:layout_height=48dp? ?? ?? ?? ?android:text=@string/stopbtn /? ? /LinearLayout? ? TextView? ?? ???android:id=@+id/tv? ?? ???android:layout_width=fill_parent? ?? ???android:layout_height=wrap_content? ?? ???android:layout_marginLeft=4dp? ?? ???android:layout_marginTop=10dp? ?? ???android:text=@string/defaultshow? ?? ???android:textSize=18sp //LinearLayout首先写后台的LBSServiceListener 实现LocationListener接口,在这个LBSServiceListener 中可以重写方法,代码如下:package com.exams.demo10_lbs;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.GregorianCalendar;import java.util.TimeZone;import android.location.Location;import android.location.LocationListener;import android.os.Bundle;import android.util.Log;public class LBSServiceListener implements LocationListener {public int GPSCurrentStatus;public Location currentLocation;public void onLocationChanged(Location location) {??// TODO Auto-generated method stub??//-------??// Called when a new location is found by the location provider.??if (currentLocation != null) {?
您可能关注的文档
- 本部简绪论上皮组织2016年本科讲义.ppt
- 20151026控制电机例析.ppt
- 本次出行有些走马观花讲义.doc
- 本次考试成绩6讲义.doc
- 本地020电商平台“幸福城市”可行性讲义.doc
- 20160107现代生物进化理论的由来例析.ppt
- 20160123孝感市镇综合发展能力排名例析.doc
- 爱心公寓家庭篇详解.doc
- 201505224-2矩阵与变换作业1例析.doc
- 开发者技术及生态发展2030.pdf
- 全过程工程管理造价咨询工程监理项目服务方案投标方案(技术部分).doc
- 招标代理服务投标技术服务方案(技术方案).doc
- AI大模型与AIGC技术在公安领域的应用解决方案(99页 PPT).pptx
- 工业4.0智能制造数字工厂规划方案.pptx
- 树立社会主义核心价值观.docx
- 三年(2023-2025)中考历史真题分类汇编(全国)专题21 科技文化与社会生活(解析版).docx
- 2025年中考道德与法治真题完全解读(吉林卷).pdf
- 2025年中考道德与法治真题完全解读(安徽卷).pdf
- 三年(2023-2025)中考历史真题分类汇编(全国)专题14 人民解放战争(解析版).pdf
- 三年(2023-2025)广东中考历史真题分类汇编:专题03 中国近代史(八年级上册)(解析版).docx
原创力文档

文档评论(0)