android定位問題

來源:互聯網
上載者:User

標籤:android   io   ar   使用   sp   資料   on   art   問題   

============問題描述============


各位大神:
如何將GPS,基站定位,WiFi定位有效整合到一起,讓系統根據網路化境做出有效定位方式,謝謝啦

============解決方案1============


樓上說的對,實現locationlistener的onLocationChanged,onProviderDisabled,onProviderEnabled,onStatusChanged介面。

============解決方案2============


但是基站定位和wifi定位(IP)還是需要第三方包依賴的啊,否則你就得自己搭建基站資料庫,拿到所有基站的資料,ip也是一樣,才能進行解析。

============解決方案3============


如此 你就註冊了兩個 provider , GPS_PROVIDER & NETWORK_PROVIDER。 但是還是有問題 gps 精度高 可靠, 但是穩定性差 , network方式 速度快 但是不可靠 ,因為位置取決於你使用的代理等原因。至於你的初衷“系統根據網路化境做出有效定位方式” ,這個可以做一個互動選擇讓使用者自行選定  如果gps獲得不了位置 使用網路位置,如果兩種方式都有位置資訊,且誤差超過一定程度 ,讓使用者自行決定想使用哪個。
引用 9 樓 tomkan 的回複:
private android.location.LocationManager mLocationManager;
LocationListener [] mLocationListeners = new LocationListener[] {
            new LocationListener(android.location.LocationManager.GPS_PROVIDER),
            new LocationListener(android.location.LocationManager.NETWORK_PROVIDER)
    };
if (mLocationManager == null) {
            mLocationManager = (android.location.LocationManager)
                    mContext.getSystemService(Context.LOCATION_SERVICE);
        }
        if (mLocationManager != null) {
            try {
                mLocationManager.requestLocationUpdates(
                        android.location.LocationManager.NETWORK_PROVIDER,
                        1000,
                        0F,
                        mLocationListeners[1]);
            } catch (SecurityException ex) {
                Log.i(TAG, "fail to request location update, ignore", ex);
            } catch (IllegalArgumentException ex) {
                Log.d(TAG, "provider does not exist " + ex.getMessage());
            }
            try {
                mLocationManager.requestLocationUpdates(
                        android.location.LocationManager.GPS_PROVIDER,
                        1000,
                        0F,
                        mLocationListeners[0]);
               
            } catch (SecurityException ex) {
                Log.i(TAG, "fail to request location update, ignore", ex);
            } catch (IllegalArgumentException ex) {
                Log.d(TAG, "provider does not exist " + ex.getMessage());
            }
            Log.d(TAG, "startReceivingLocationUpdates");
        }

android定位問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.