电子信息学院实验报告书课程名:《操作系统原理》题目:实验六Android的GPS与谷歌地图应用实验类别:【验证、设计】班级:学号:姓名:评语:学习态度□积极□一般□较差原理阐述□清晰□基本清晰□不清晰实验结果□正确□基本正确□部分正确思考题探究□深入□较深入□未做答书写规范性□规范□基本符合要求□未符合要就成绩:指导教师:林晓晨批阅时间:年月日《操作系统原理》实验报告-1-1、实验题目Android的GPS与谷歌地图应用2、实验目的与要求(1)实验目的:本次实验的目的是让同学熟悉Android中GoogleMap和GPS的使用。(2)实验要求:1.了解基于位置的服务和模拟位置提供器;2.学会使用模拟器来测试定位服务。3、实验步骤与源程序(1)MainActivity.javapackagelin.example.hellomap;importjava.util.List;importandroid.app.Activity;importandroid.content.Context;importandroid.location.Location;importandroid.location.LocationListener;importandroid.location.LocationManager;importandroid.os.Bundle;importandroid.widget.TextView;publicclassMainActivityextendsActivity{privateLocationManagerlocationManager;privateTextViewtv;@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);locationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);tv=(TextView)findViewById(R.id.textView1);《操作系统原理》实验报告-2-locate();}privatevoidlocate(){StringBuilderbuilder=newStringBuilder(可利用的providers:);ListStringproviders=locationManager.getProviders(true);LocationListenerll=newLocationListener(){@OverridepublicvoidonLocationChanged(Locationlocation){}@OverridepublicvoidonProviderDisabled(Stringprovider){}@OverridepublicvoidonProviderEnabled(Stringprovider){}@OverridepublicvoidonStatusChanged(Stringprovider,intstatus,Bundleextras){}};for(Stringprovider:providers){locationManager.requestLocationUpdates(provider,0,1000,ll);builder.append(provider).append(\n);Locationlocation=locationManager.getLastKnownLocation(provider);if(location!=null){doublelat=location.getLatitude();doublelng=location.getLongitude();builder.append(();builder.append(lat);builder.append(');builder.append(lng);builder.append());}else{builder.append(没有位置信息);}}tv.setText(builder);}}《操作系统原理》实验报告-3-(2)activity_main.xmlFrameLayoutxmlns:android=:tools=:id=@+id/containerandroid:layout_width=match_parentandroid:layout_height=match_parenttools:context=lin.example.hellomap.MainActivitytools:ignore=MergeRootFrameTextViewandroid:id=@+id/textView1android:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:text=//FrameLayout《操作系统原理》实验报告-4-(3)AndroidManifest.xml?xmlversion=1.0encoding=utf-8?manifestxmlns:android==lin.example.hellomapandroid:versionCode=1android:versionName=1.0uses-sdkandroid:minSdkVersion=8android:targetSdkVersion=19/applicationandroid:allowBackup=trueandroid:icon=@drawable/ic_launcherandroid:label=@string/app_nameandroid:theme=@style/AppThemeactivityandroid:name=lin.example.hellomap.MainActivityandroid:label=@string/app_nameintent-filteractionandroid:name=android.intent.action.MAIN/categoryandroid:name=android.intent.category.LAUNCHER//intent-filter/activity/applicationuses-permissionandroid:name=android.permission.ACCESS_FINE_LOCATION/uses-permissionandroid:name=android.permission.ACCESS_COARSE_LOCATION//manifest《操作系统原理》实验报告-5-(4)使用DDMS发送虚拟经纬度(4.1)运行程序,得到如下AVD界面《操作系统原理》实验报告-6-《操作系统原理》实验报告-7-(4.2)然后打开DDMS(4.3)选中AVD,利用EmulatorControl发送虚拟经纬度《操作系统原理》实验报告-8-(4.4)重新回到AVD的Hellomap界面,可以看到经纬度显示。《操作系统原理》实验报告-9-5运行[2014-05-2813:22:22-hellomap]Success![2014-05-2813:22:22-hellomap]Startingactivitycom.example.hellomap.MainActivityondeviceemulator-5554[2014-05-2813:22:26-hellomap]ActivityManager:Starting:Intent{act=android.intent.action.MAINcat=[android.intent.category.LAUNCHER]cmp=com.example.hellomap/.MainActivity}[2014-05-2813:32:59-hellomap]------------------------------[2014-05-2813:32:59-hellomap]AndroidLaunch![2014-05-2813:32:59-hellomap]adbisrunningnormally.[2014-05-2813:32:59-hellomap]Performingcom.example.hellomap.MainActivityactivitylaunch[2014-05-2813:32:59-hellomap]AutomaticTargetMode:PreferredAVD'AVD_for_3_7_WVGA_Nexus_One'isnotavailable.Launchingnewemulator.[2014-05-2813:32:59-hellomap]LaunchinganewemulatorwithVirtualDevice'AVD_for_3_7_WVGA_Nexus_One'[2014-05-2813:33:11-Emulator]emulator:warning:openingaudiooutputfailed[2014-05-2813:33:11-Emulator][2014-05-2813:33:11-hellomap]Newemulatorfound:emulator-5554[2014-05-2813:33:11-hellomap]WaitingforHOME('android.process.acore')tobelaunched...[2014-05-2813:34:00-hellomap]HOMEisupondevice'emulator-5554'[2014-05-2813:34:00-hellomap]Uploadinghellomap.apkontodevice'emulator-5554'[2014-05-2813:34:00-hellomap]Installinghellomap.apk...[2014-05-2813:34:36-hellomap]Success![2014-05-2813:34:36-hellomap]Startingactivitycom.example.hellomap.MainActivityondeviceemulator-5554[2014-05-2813:34:40-hellomap]ActivityManager:Starting:Intent{act=android.intent.action.MAINcat=[android.intent.category.LAUNCHER]cmp=com.example.hellomap/.MainActivity}Console:Android[2014-05-1502:23:06-Hellomap]------------------------------[2014-05-1502:23:06-Hellomap]AndroidLaunch![2014-05-1502:23:06-Hellomap]adbisrunningnormally.[2014-05-1502:23:06-Hellomap]Performinglin.example.hellomap.MainActivityactivitylaunch