【问题标题】:How to push a location to emulator?如何将位置推送到模拟器?
【发布时间】:2012-05-21 21:33:40
【问题描述】:

我想在模拟器中设置一个点作为当前位置?我在 DDMS 中使用位置控制,但它不起作用!任何机构都知道如何解决这个问题?提前致谢!!

【问题讨论】:

  • 0_0,有些链接在中国被屏蔽了,可能链接www.helloandroid.com被收录了!!!
  • 好的,按照步骤操作, 1. 转到您的 android/tools 目录,然后启动 DDMS 工具 2. 选择 Emulator Control 选项卡 3. 用经度和纬度值填写 Location Controls 字段 4 .按发送按钮
  • 我试过DDMS的位置控制和telnet,都失败了!

标签: android android-emulator


【解决方案1】:

试试这个,

public class NL extends Activity {

    private LocationManager locmgr = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nl);

        locmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

     // Define a listener that responds to location updates
        LocationListener locationListener = new LocationListener() {
            public void onLocationChanged(Location loc) {
              // Called when a new location is found by the network location provider.
                Log.i("NOTIFICATION","onLocationChenged Triggered");

                Toast msg = Toast.makeText(NetworkLocator.this, "Lon: " + Double.toString(loc.getLongitude()) + " Lat: " + Double.toString(loc.getLatitude()), Toast.LENGTH_SHORT);
                msg.show();
            }

            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
        locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
    }
}

引用自Android - Unable to get the gps location on the emulator

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 2021-07-03
    • 1970-01-01
    相关资源
    最近更新 更多