Java 在检查了各个地方之后,程序在android/Eclipse中返回相同的经度和纬度
我正在使用eclipse。源代码如下: 当我在不同的地方点击第一个按钮时,结果是一样的。请帮忙。。提前谢谢 GPSSurvey舱单Java 在检查了各个地方之后,程序在android/Eclipse中返回相同的经度和纬度,java,android,eclipse,Java,Android,Eclipse,我正在使用eclipse。源代码如下: 当我在不同的地方点击第一个按钮时,结果是一样的。请帮忙。。提前谢谢 GPSSurvey舱单 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.vinod.gpssurvey" android:versionCode="1" android:versi
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vinod.gpssurvey"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.vinod.gpssurvey.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
}
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/FirstLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Longitute : " />
<TextView
android:id="@+id/FirstLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Latitute : " />
<Button
android:id="@+id/Firstbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="First Corner" />
<TextView
android:id="@+id/SecLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sec Longitute : " />
<TextView
android:id="@+id/SecLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sec Latitute : " />
<Button
android:id="@+id/Firstbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Second Corner" />
<TextView
android:id="@+id/ThirdLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Third Longitute : " />
<TextView
android:id="@+id/ThirdLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Third Latitute : " />
<Button
android:id="@+id/Thirdbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Third Corner" />
<TextView
android:id="@+id/FourthLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fourth Longitute : " />
<TextView
android:id="@+id/FourthLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fourth Latitute : " />
<Button
android:id="@+id/Fourthtbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fourth Corner" />
<TextView
android:id="@+id/FifthLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fifth Longitute : " />
<TextView
android:id="@+id/FifthtLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fifth Latitute : " />
<Button
android:id="@+id/Fifthbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fifth Corner" />
</LinearLayout>
当LocationProvider(通常是GPS或WiFi)处于活动状态且实际检测到位置时,对
getLastKnownLocation
的调用将为您提供上次检测到的位置
根据您的设备,GPS提供商提供第一个位置可能需要一段时间(如1分钟或更长时间)。您可以在导航栏上看到连接到GPS卫星的状态(同样,取决于您使用的设备)
如果你在室内,它可能永远不会收到任何位置
我看你的代码还可以。你在使用emulator吗?欢迎来到StackOverFlow,@Vinod,你在各个地方是如何检查的?通过一个真正的设备?我正在通过一个真正的设备,三星Grand Mobile进行检查。我必须得到一个图的坐标。我走到绘图的每个角落,按下第一个角落的按钮。但结果是一样的。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/FirstLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Longitute : " />
<TextView
android:id="@+id/FirstLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Latitute : " />
<Button
android:id="@+id/Firstbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="First Corner" />
<TextView
android:id="@+id/SecLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sec Longitute : " />
<TextView
android:id="@+id/SecLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sec Latitute : " />
<Button
android:id="@+id/Firstbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Second Corner" />
<TextView
android:id="@+id/ThirdLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Third Longitute : " />
<TextView
android:id="@+id/ThirdLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Third Latitute : " />
<Button
android:id="@+id/Thirdbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Third Corner" />
<TextView
android:id="@+id/FourthLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fourth Longitute : " />
<TextView
android:id="@+id/FourthLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fourth Latitute : " />
<Button
android:id="@+id/Fourthtbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fourth Corner" />
<TextView
android:id="@+id/FifthLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fifth Longitute : " />
<TextView
android:id="@+id/FifthtLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fifth Latitute : " />
<Button
android:id="@+id/Fifthbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fifth Corner" />
</LinearLayout>