Android-GPS模拟器错误测试
我想在我的android模拟器上测试GPS,但当我尝试在模拟器上运行时,我发现我的应用程序出现了错误“意外停止” 这是我的一些代码 AndroidManifest.xmlAndroid-GPS模拟器错误测试,android,android-emulator,android-manifest,Android,Android Emulator,Android Manifest,我想在我的android模拟器上测试GPS,但当我尝试在模拟器上运行时,我发现我的应用程序出现了错误“意外停止” 这是我的一些代码 AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permi
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
在my main.java上导入
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager locationManager;
String context = Context.LOCATION_SERVICE;
locationManager = (LocationManager)getSystemService(context);
String provider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);
updateWithNewLocation(location);
}
private void updateWithNewLocation(Location location){
String latLongString;
TextView myLocationText;
myLocationText = (TextView)findViewById(R.id.myLocationText);
if(location != null){
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "Lat:" + lat + "\nLong:" + lng;
}else{
latLongString = "No location found";
}
myLocationText.setText("Your Current Position is: \n" + latLongString);
}
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
你能告诉我为什么我的应用程序在我的模拟器上运行时出现错误“意外停止”吗
谢谢你帮我:)
跟踪错误:“java.lang.NullPointerException”
我一直在使用DDMS将long和lat设置为:
长:112.801100
lat:-7.2950700您可以在模拟器中模拟该位置 提供模拟位置数据 在开发应用程序时,您当然需要测试其性能 您获取用户位置的模型有效。这是最容易做到的 使用真正的安卓系统 装置。但是,如果您没有设备,您仍然可以测试您的设备 通过在Android emulator中模拟位置数据实现基于位置的功能。 有三种不同的方式发送应用程序模拟位置数据: 在emulator控制台中使用Eclipse、DDMS或“geo”命令 注:提供模拟位置数据作为GPS位置数据注入, 因此,您必须向GPS_提供商请求位置更新,以便进行模拟 位置数据要工作 使用Eclipse 选择窗口>显示视图>其他>仿真器控件 在Emulator控制面板中,输入GPS坐标 在位置控制下,作为单个横向/纵向坐标, 使用GPX文件播放路线,或使用KML文件播放路线 多个地方标记。(请确保已选择设备 在“设备”面板中,可从“窗口>显示视图>其他>设备”获得。) 使用DDMS 使用DDMS工具,您可以通过几种不同的方式模拟位置数据: 手动将各个经度/纬度坐标发送到设备。 使用GPX文件描述播放到设备的路径。 使用KML文件描述序列的各个位置标记 播放到设备。 有关使用DDMS欺骗位置数据的更多信息,请参阅使用DDMS 在emulator控制台中使用“geo”命令 要从命令行发送模拟位置数据,请执行以下操作: 在Android emulator中启动应用程序并打开终端/控制台 在SDK的/tools目录中。 连接到emulator控制台: telnet本地主机 发送位置数据: geo fix发送一个固定的地理位置。 此命令接受以十进制度数表示的经度和纬度,以及 以米为单位的可选高度。例如: 地理定位-121.45356 46.51119 4392 geo nmea发送nmea 0183语句。 此命令接受单个NMEA语句,类型为“$GPGGA”(修复数据)或 “$GPRMC”(运输数据)。例如: geo nmea$GPRMC,081836,A,3751.65,S,14507.36,E,000.0360.0130998011.3,E*62 有关如何连接到emulator控制台的信息,请参阅使用
仿真器控制台。最好为错误提供stacktrace。+1非常好的答案!感谢您的帮助,但问题是当我尝试在emulator上运行我的应用时,它的“给我”错误“意外停止”