Exemplo n.º 1
0
 public void StartLocation()
 {
     try {
         jcu             = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
         jou             = jcu.GetStatic <AndroidJavaObject>("currentActivity");
         mLocationClient = new AndroidJavaObject("com.amap.api.location.AMapLocationClient", jou);
         mLocationOption = new AndroidJavaObject("com.amap.api.location.AMapLocationClientOption");
         mLocationClient.Call("setLocationOption", mLocationOption);
         amap = new AmapEvent();
         amap.locationChanged += OnLocationChanged;
         mLocationClient.Call("setLocationListener", amap);
         mLocationClient.Call("startLocation");
     } catch (Exception ex) {
         Debug.Log(ex.Message);
         EndLocation();
     }
 }
Exemplo n.º 2
0
    public void StartLocation()
    {
        try
        {
            txtInfo.text = "start location...";

            txtInfo.text = txtInfo.text + "\r\n";
            jcu          = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            jou          = jcu.GetStatic <AndroidJavaObject>("currentActivity");
            txtInfo.text = txtInfo.text + "currentActivity get...";

            txtInfo.text    = txtInfo.text + "\r\n";
            mLocationClient = new AndroidJavaObject("com.amap.api.location.AMapLocationClient", jou);
            txtInfo.text    = txtInfo.text + "AMapLocationClient get...";

            txtInfo.text    = txtInfo.text + "\r\n";
            mLocationOption = new AndroidJavaObject("com.amap.api.location.AMapLocationClientOption");
            txtInfo.text    = txtInfo.text + "AMapLocationClientOption get...";

            txtInfo.text = txtInfo.text + "\r\n";
            mLocationClient.Call("setLocationOption", mLocationOption);
            txtInfo.text = txtInfo.text + "setLocationOption...";

            amap = new AmapEvent();
            amap.locationChanged += OnLocationChanged;

            txtInfo.text = txtInfo.text + "\r\n";
            mLocationClient.Call("setLocationListener", amap);
            txtInfo.text = txtInfo.text + "setLocationListener...";

            txtInfo.text = txtInfo.text + "\r\n";
            mLocationClient.Call("startLocation");
            txtInfo.text = txtInfo.text + "startLocation...";
        }
        catch (Exception ex)
        {
            txtInfo.text = txtInfo.text + "\r\n";
            txtInfo.text = txtInfo.text + "--------------------";
            txtInfo.text = txtInfo.text + ex.Message;

            EndLocation();
        }
    }
Exemplo n.º 3
0
 /// <summary>
 /// 返回定位信息
 /// </summary>
 private void StartLocationChanged()
 {
     //声明定位回调监听器
     _amap = new AmapEvent();
     _amap.LocationChanged += OnLocationChanged;
 }