Android开经度和纬度的Andr​​oid模拟器 [英] android get latitude and longitude on emulator of android

查看:178
本文介绍了Android开经度和纬度的Andr​​oid模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜iwant检查纬度长的当前位置在Android模拟器如何才达到这个.. ??就可以获取当前位置的经度和纬度上的模拟器???如果是的话那么什么设置需要在模拟器?

  @覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.main);

    LocationManager LM =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
    LocationListener的LL =新Mylocationlistener();

    布尔isGPS = LM
            .isProviderEnabled(LocationManager.GPS_PROVIDER);

    //如果GPS是不是能够那么这将是对
    如果(!isGPS)
    {
        意向意图=新的意图(android.location.GPS_ENABLED_CHANGE);
        intent.putExtra(已启用,真正的);
         sendBroadcast(意向);


    }

    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,LL);
}
私有类Mylocationlistener实现LocationListener的{
    @覆盖
    公共无效onLocationChanged(位置定位){
        如果(位置!= NULL){
            Log.d(位置发生改变,location.getLatitude()+);
            Log.d(位置发生改变,location.getLongitude()+);
            浮动速度= location.getSpeed​​();
            双高度= location.getAltitude();
            Toast.makeText(currentlatlong.this,纵横=+
                    location.getLatitude()++经度=+ location.getLongitude()+高度=+高度+速度=+速度,
                    Toast.LENGTH_LONG).show();
        }
    }

    @覆盖
    公共无效onProviderDisabled(字符串提供商){
    }

    @覆盖
    公共无效onProviderEnabled(字符串提供商){
    }

    @覆盖
    公共无效onStatusChanged(字符串商,INT地位,捆绑演员){
    }
}
 

解决方案

您会发现在DDMS透视图在Eclipse这个窗口。这样,您就可以与各种位置值测试您的应用程序。

hi iwant to check lat long of current position in android emulator how to achive this..??it is possible to get current position latitude and longitude on emulator???if yes then what setting is required in emulator?

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

    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    LocationListener ll = new Mylocationlistener();

    boolean isGPS = lm
            .isProviderEnabled(LocationManager.GPS_PROVIDER);

    // If GPS is not enable then it will be on
    if(!isGPS)
    {
        Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
        intent.putExtra("enabled", true);
         sendBroadcast(intent);


    }

    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
}
private class Mylocationlistener implements LocationListener {
    @Override
    public void onLocationChanged(Location location) {
        if (location != null) {
            Log.d("LOCATION CHANGED", location.getLatitude() + "");
            Log.d("LOCATION CHANGED", location.getLongitude() + "");
            float speed = location.getSpeed();
            double altitude = location.getAltitude();
            Toast.makeText(currentlatlong.this,"Latitude = "+
                    location.getLatitude() + "" +"Longitude = "+ location.getLongitude()+"Altitude = "+altitude+"Speed = "+speed,
                    Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public void onProviderDisabled(String provider) {
    }

    @Override
    public void onProviderEnabled(String provider) {
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
    }
}

解决方案

You'll find this window in the DDMS perspective in Eclipse. This way you can test your application with various location values.

这篇关于Android开经度和纬度的Andr​​oid模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆