Android 未在GPU中显示位置
我已经在emulator中检查了主机GPU,并试图获取当前位置,但没有得到任何结果,既没有错误也没有结果 这是我的密码Android 未在GPU中显示位置,android,android-emulator,gps,locationmanager,Android,Android Emulator,Gps,Locationmanager,我已经在emulator中检查了主机GPU,并试图获取当前位置,但没有得到任何结果,既没有错误也没有结果 这是我的密码 package com.example.locationawareapp; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android
package com.example.locationawareapp;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView currentloc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
currentloc = (TextView)findViewById(R.id.CurrentLocation);
// Acquire a reference to the system Location Manager
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
}
protected void makeUseOfNewLocation(Location location) {
// TODO Auto-generated method stub
currentloc.setText(new Double(location.getLatitude()).toString());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
谁能帮我弄到这个。我已经检查了一些存在的问题,但问题尚未解决
问候,苏拉布我找到了答案: 让我分享我的理解,解释正在发生的事情、我们需要做什么以及为什么 Emulator没有任何可以使用的内置GPS硬件,但LocationManager类及其方法实现将在接收到位置信息时执行该任务。由于emulator没有内置硬件,我们必须为在emulator上运行的应用程序提供Lat-Lon。要提供位置信息,我们可以使用下面的命令行
telnet localhost 5554
geo fix <longitude value> <latitude value>
telnet本地主机5554
地理定位
我还使用了一种简单的方法,就是使用EclipseUI,即插入DDMS函数来发送GPS。
在eclipse中,进入窗口>打开透视图>DDMS。
在DDMS中,您将看到如下所示的图片
首先进入eclipse中的DDMS部分,然后打开emulator控件。。。。转到手动部分设置横向和纵向,然后按下发送按钮
希望这能对您有所帮助。您如何为模拟器提供位置?DDMS<模拟器控制台中的code>geo命令?我不知道。我只想运行上面的代码。互联网上有很多Android开发者支持网站,提供多种语言的帮助。我在网站上列出了几个网站。你将有更好的运气使用一个网站,是在一个更舒适的语言为你。