久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='QTTrz'></tfoot>

      <bdo id='QTTrz'></bdo><ul id='QTTrz'></ul>

    <small id='QTTrz'></small><noframes id='QTTrz'>

  1. <legend id='QTTrz'><style id='QTTrz'><dir id='QTTrz'><q id='QTTrz'></q></dir></style></legend>

    1. <i id='QTTrz'><tr id='QTTrz'><dt id='QTTrz'><q id='QTTrz'><span id='QTTrz'><b id='QTTrz'><form id='QTTrz'><ins id='QTTrz'></ins><ul id='QTTrz'></ul><sub id='QTTrz'></sub></form><legend id='QTTrz'></legend><bdo id='QTTrz'><pre id='QTTrz'><center id='QTTrz'></center></pre></bdo></b><th id='QTTrz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QTTrz'><tfoot id='QTTrz'></tfoot><dl id='QTTrz'><fieldset id='QTTrz'></fieldset></dl></div>
    2. NETWORK_PROVIDER 的 LocationListener 已啟用,但永遠不會

      LocationListener of NETWORK_PROVIDER is enabled but , onLocationChanged is never called(NETWORK_PROVIDER 的 LocationListener 已啟用,但永遠不會調用 onLocationChanged)

      • <i id='MB1Zg'><tr id='MB1Zg'><dt id='MB1Zg'><q id='MB1Zg'><span id='MB1Zg'><b id='MB1Zg'><form id='MB1Zg'><ins id='MB1Zg'></ins><ul id='MB1Zg'></ul><sub id='MB1Zg'></sub></form><legend id='MB1Zg'></legend><bdo id='MB1Zg'><pre id='MB1Zg'><center id='MB1Zg'></center></pre></bdo></b><th id='MB1Zg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MB1Zg'><tfoot id='MB1Zg'></tfoot><dl id='MB1Zg'><fieldset id='MB1Zg'></fieldset></dl></div>
            <bdo id='MB1Zg'></bdo><ul id='MB1Zg'></ul>
            1. <small id='MB1Zg'></small><noframes id='MB1Zg'>

              <legend id='MB1Zg'><style id='MB1Zg'><dir id='MB1Zg'><q id='MB1Zg'></q></dir></style></legend>
                <tbody id='MB1Zg'></tbody>

                <tfoot id='MB1Zg'></tfoot>

                本文介紹了NETWORK_PROVIDER 的 LocationListener 已啟用,但永遠不會調用 onLocationChanged的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在開發一個應用程序,該應用程序可以在服務中的 6 分鐘和 6 分鐘內全天獲取手機的位置,它工作正常,但有時網絡提供商偵聽器的方法 OnLocationChanged 停止存在打電話,我不知道為什么.

                I am developing an application that gets position of the cell phone all day long in 6 and 6 minutes in a service, it works fine but sometimes the method OnLocationChanged of the Network provider listener stop to being called, and I don't know why.

                它由于某種原因停止被調用,但是提供程序已啟用并且列表器正在工作,當我手動啟用或禁用提供程序時,會調用 onProviderEnabledonProviderDisabled.

                It for some reason stop being called, but the Provider is enable and the Lister is working, when I Enable or disable the Provider manually, onProviderEnabled and onProviderDisabled is called.

                這只是發生在 NETWORK_PROVIDER 上,GPS_PROVIDER 運行良好.

                It just happens with NETWORK_PROVIDER, the GPS_PROVIDER works well.

                聽眾:

                LocationListener locationListenerGPS = new LocationListener() {
                        // @Override
                        public void onStatusChanged(String provider, int status, Bundle extras) {
                            // TODO locationListenerGPS onStatusChanged
                            Log.d(TAG, "Provedor trocado");
                        }
                
                        // @Override
                        public void onProviderEnabled(String provider) {
                            Log.w(TAG, "PROVEDOR " + provider + " HABILITADO!");
                        }
                
                        // @Override
                        public void onProviderDisabled(String provider) {
                            Log.w(TAG, "PROVEDOR " + provider + " DESABILITADO!");
                        }
                
                        // @Override
                        public void onLocationChanged(Location location) {
                
                            longitudeGPS = location.getLongitude();
                            latitudeGPS = location.getLatitude();
                            Log.d(TAG,"LocationChangedGPS LAT: "+latitudeGPS+" longi: "+longitudeGPS);
                            gpsComSinal = true;
                        }
                    };
                
                    LocationListener locationListenerNET = new LocationListener() {
                
                        // @Override
                        public void onStatusChanged(String provider, int status, Bundle extras) {
                            // TODO locationListenerNET onStatusChanged
                            Log.d("Contele", "Provedor foi mudado");
                        }
                
                        // @Override
                        public void onProviderEnabled(String provider) {
                            Log.i(TAG, "PROVEDOR " + provider + " HABILITADO!");
                        }
                
                        // @Override
                        public void onProviderDisabled(String provider) {
                            Log.i(TAG, "PROVEDOR " + provider + " DESABILITADO!");
                        }
                
                        @Override
                        public void onLocationChanged(Location location) {
                            longitudeNET = location.getLongitude();
                            latitudeNET = location.getLatitude();
                            Log.d(TAG,"LocationChangedNET LAT: "+latitudeNET+" longi: "+longitudeNET);
                            netComSinal = true;
                        }
                    };
                

                代碼:

                public void initProviders() {
                
                        localizacao = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
                
                
                        localizacao.removeUpdates(locationListenerNET);
                        localizacao.removeUpdates(locationListenerGPS);
                
                        localizacao.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                                locationListenerGPS);
                
                        localizacao.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,
                                0, locationListenerNET);
                
                        Log.d(TAG,"EsperaGPS");
                        Handler esperaGPS = new Handler() {
                            public void handleMessage(Message msg) {
                
                                requestGPS();
                            }
                        };
                
                        Message msgEsperaGPS = Message.obtain();
                        msgEsperaGPS.what = 0;
                        esperaGPS.sendMessageDelayed(msgEsperaGPS, 35000);
                    }
                
                
                
                    public void requestGPS() {
                            if (gpsComSinal) {
                                Log.d(TAG,"PEGO SINAL DE GPS");
                                rastreio = "GPS";
                                longitude = longitudeGPS;
                                latitude = latitudeGPS;
                                Log.d(TAG, "Utilizando provedor GPS.");
                                localizacao.removeUpdates(locationListenerGPS);
                                localizacao.removeUpdates(locationListenerNET);
                
                            } else {
                                Log.d(TAG,"Sem GPS... pegar NEt");
                                // Setando os valores para usar network
                                localizacao.removeUpdates(locationListenerGPS);
                                localizacao.removeUpdates(locationListenerNET);
                                localizacao
                                        .requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
                                                0, 0, locationListenerNET);
                                Log.d(TAG,"EsperaNET");
                
                                        requestNET();
                            }
                        }
                
                    public void requestNET() {
                            if (netComSinal) {
                                Log.d(TAG,"PEGO SINAL DE NET");
                                rastreio = "NET";
                                longitude = longitudeNET;
                                latitude = latitudeNET;
                                Log.d(TAG, "Utilizando provedor NET.");
                                localizacao.removeUpdates(locationListenerNET);
                
                            } else {
                                localizacao.removeUpdates(locationListenerGPS);
                                localizacao.removeUpdates(locationListenerNET);
                                Log.d(TAG,"Sem sinal");
                            }
                        }
                

                三星 Galaxy S3 中的報告:

                Report in a Samsung Galaxy S3:

                仍然連續 4 天收到Sem sinal".

                Still getting "Sem sinal" for 4 days in a row.

                Galaxy Y 和 LG Optimus l5 已經出現此問題

                This issue have already happened with Galaxy Y and LG Optimus l5

                我進行了另一項測試,看看其他應用程序是否獲得了 NET 位置,我發現它們通過了同樣的問題,它們無法僅通過 GetLastknowLocation 獲得 NET 位置;測試我使用 Galaxy S3 解決了這個問題,并禁用了 GPS Provider.(在 Cerberus 中測試).

                I have made another test to see if other aplications got the NET positions, and I discovered that they are passing for the same problem, they can't get the NET position just the GetLastknowLocation; to test that I used a Galaxy S3 with this problem, and I disabled the GPS Provider. (Tested in Cerberus).

                我找不到任何解釋為什么 NETWORKSLOCATIONS 聽眾停止給出位置,但這可能是因為它不應該連續工作 2 或 3 天.

                I couldn't find any explanation for why NETWORKSLOCATIONS listener stop giving positions, but it might be because it shouldn't work for 2 or 3 days without stop.

                我已經對其他應用程序進行了一些測試,看看這個問題是否只是在我的應用程序中發生,我發現它們正在通過同樣的問題,例如在 Cerberus 中:

                I have done some tests with other aplications to see if this issue is just happening with my aplication, and I discovered that they are passing for same problem, like in Cerberus for example :

                我在手機 (Galaxy S3) 中禁用 GPS 提供程序,出現Sem sinal"問題,看看:

                I disable the GPS Provider in a cellphone (Galaxy S3) with the "Sem sinal" problem, take a look:

                我的報告:

                和 Cerberus(打印于 2013 年 5 月 14 日)報告:

                And Cerberus(print taken in 14/05/2013) report:

                但是當我打開谷歌地圖時,它似乎工作正常,我試圖移動到一個較遠的地方,看看它是否會顯示 GetLastknowLocation ,但是沒有,谷歌地圖把我放在正確的地方,所以我意識到谷歌地圖正在使用motionevent在地圖中移動我;

                But When I opened the Google Maps it seems to work OK, I tried to move to a distance place to see if it going to show the GetLastknowLocation , but no, google maps put me in the right place in the moment, so I realized that Google Maps was using motionevent to move me in the map;

                同時打印 Google Maps 的 Log 以獲取 NetWorkProvider:

                And also print the Log of Google Maps to get NetWorkProvider:

                正常情況:

                句號:

                推薦答案

                我在 Network provider 遇到過類似的問題,唯一的解決方案是強制設備重啟.盡管谷歌地圖總是顯示正確的位置,因為它使用了除了網絡位置提供者之外的其他傳感器信息.

                i have experienced similar issues with Network provider and only solution was force device restart. Though google map was showing always correct location, because it uses other sensors information also apart from Network location provider.

                但這是好消息,不是很久以前 Google 通過其 Google Play 服務框架,比 GPS/網絡位置提供商超級好用.

                But here is good news, not Long time back Google introduced Fused Location Provider api's via its Google Play Service Framework which is super easy to use than GPS / Network Location providers.

                兼容 API 級別 8,現在當我遇到網絡提供商這個奇怪的問題時,同時融合位置給了我準確的位置(無需重啟設備).

                Compatible upto API Level 8, now when i get this weird issue of Network provider, same time Fused Location gives me accurate location(without device restart).

                我已經提交了一個工作FusedLocation 測試項目在這里,你可以自己克隆和測試..

                I have commited one working FusedLocation Test Project here, you can clone and test yourself..

                下面是代碼片段:-

                package com.example.fusedLoctionTest.service;
                
                import android.app.Service;
                import android.content.Context;
                import android.content.Intent;
                import android.location.Location;
                import android.location.LocationManager;
                import android.os.Bundle;
                import android.os.Handler;
                import android.os.IBinder;
                import android.support.v4.content.LocalBroadcastManager;
                import android.util.Log;
                import com.google.android.gms.common.ConnectionResult;
                import com.google.android.gms.common.GooglePlayServicesClient;
                import com.google.android.gms.location.LocationClient;
                import com.google.android.gms.location.LocationRequest;
                
                public class FusedLocationService extends Service implements GooglePlayServicesClient.ConnectionCallbacks,
                        GooglePlayServicesClient.OnConnectionFailedListener, com.google.android.gms.location.LocationListener{
                    private static final LocationRequest REQUEST = LocationRequest.create()
                            .setInterval(0)
                            .setFastestInterval(0)
                            .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
                    public static final String LOCATION_RECEIVED = "fused.location.received";
                    private Long now;
                
                    private LocationClient mLocationClient;
                    private final Object locking = new Object();
                    private Runnable onFusedLocationProviderTimeout;
                    private Handler handler = new Handler();
                
                    @Override
                    public int onStartCommand(Intent intent, int flags, int startId) {
                        super.onStartCommand(intent, flags, startId);
                        now = Long.valueOf(System.currentTimeMillis());
                        mLocationClient = new LocationClient(this, this, this);
                        mLocationClient.connect();
                        return START_STICKY;
                    }
                
                    @Override
                    public void onConnected(Bundle bundle) {
                        Log.d("FusedLocationService", "Fused Location Provider got connected successfully");
                        mLocationClient.requestLocationUpdates(REQUEST,this);
                        onFusedLocationProviderTimeout = new Runnable() {
                            public void run() {
                                Log.d("FusedLocationService", "location Timeout");
                
                                Location lastbestStaleLocation=getLastBestStaleLocation();
                                sendLocationUsingBroadCast(lastbestStaleLocation);
                
                                if(lastbestStaleLocation!=null)
                                    Log.d("FusedLocationService", "Last best location returned ["+lastbestStaleLocation.getLatitude()+","+lastbestStaleLocation.getLongitude()+"] in "+(Long.valueOf(System.currentTimeMillis())-now)+" ms");
                
                                if(mLocationClient.isConnected())
                                    mLocationClient.disconnect();
                            }
                        };
                        handler.postDelayed(onFusedLocationProviderTimeout, 20000);//20 sec
                    }
                
                    private void sendLocationUsingBroadCast(Location location) {
                        Intent locationBroadcast = new Intent(FusedLocationService.LOCATION_RECEIVED);
                        locationBroadcast.putExtra("LOCATION", location);
                        locationBroadcast.putExtra("TIME", Long.valueOf(System.currentTimeMillis()-now) +" ms");
                        LocalBroadcastManager.getInstance(this).sendBroadcast(locationBroadcast);
                        stopSelf();
                    }
                
                    @Override
                    public void onDisconnected() {
                        Log.d("FusedLocationService","Fused Location Provider got disconnected successfully");
                        stopSelf();
                    }
                
                    @Override
                    public void onLocationChanged(Location location) {
                        synchronized (locking){
                            Log.d("FusedLocationService", "Location received successfully ["+location.getLatitude()+","+location.getLongitude()+"] in "+(Long.valueOf(System.currentTimeMillis()-now))+" ms");
                
                            handler.removeCallbacks(onFusedLocationProviderTimeout);
                            if(mLocationClient.isConnected())
                                mLocationClient.removeLocationUpdates(this);
                
                            sendLocationUsingBroadCast(location);
                
                            if(mLocationClient.isConnected())
                                mLocationClient.disconnect();
                        }
                    }
                
                    @Override
                    public void onConnectionFailed(ConnectionResult connectionResult) {
                        Log.d("FusedLocationService", "Error connecting to Fused Location Provider");
                    }
                
                    public Location getLastBestStaleLocation() {
                        Location bestResult = null;
                        LocationManager locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                        Location lastFusedLocation=mLocationClient.getLastLocation();
                        Location gpsLocation = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        Location networkLocation = locMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                        if (gpsLocation != null && networkLocation != null) {
                            if (gpsLocation.getTime() > networkLocation.getTime())
                                bestResult = gpsLocation;
                        } else if (gpsLocation != null) {
                            bestResult = gpsLocation;
                        } else if (networkLocation != null) {
                            bestResult = networkLocation;
                        }
                
                        //take Fused Location in to consideration while checking for last stale location
                        if (bestResult != null && lastFusedLocation != null) {
                            if (bestResult.getTime() < lastFusedLocation.getTime())
                                bestResult = lastFusedLocation;
                        }
                
                        return bestResult;
                    }
                
                    @Override
                    public IBinder onBind(Intent intent) {
                        return null;
                    }
                }
                

                這篇關于NETWORK_PROVIDER 的 LocationListener 已啟用,但永遠不會調用 onLocationChanged的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                CLLocation returning negative speed(CLLocation 返回負速度)
                How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)

                    <tbody id='FTNIy'></tbody>
                  • <bdo id='FTNIy'></bdo><ul id='FTNIy'></ul>
                    <tfoot id='FTNIy'></tfoot>
                    1. <legend id='FTNIy'><style id='FTNIy'><dir id='FTNIy'><q id='FTNIy'></q></dir></style></legend>

                      <small id='FTNIy'></small><noframes id='FTNIy'>

                        <i id='FTNIy'><tr id='FTNIy'><dt id='FTNIy'><q id='FTNIy'><span id='FTNIy'><b id='FTNIy'><form id='FTNIy'><ins id='FTNIy'></ins><ul id='FTNIy'></ul><sub id='FTNIy'></sub></form><legend id='FTNIy'></legend><bdo id='FTNIy'><pre id='FTNIy'><center id='FTNIy'></center></pre></bdo></b><th id='FTNIy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FTNIy'><tfoot id='FTNIy'></tfoot><dl id='FTNIy'><fieldset id='FTNIy'></fieldset></dl></div>
                          主站蜘蛛池模板: 成人在线视频网址 | 精品国产一区二区三区久久 | 欧美日韩国产一区二区三区 | 午夜激情小视频 | 天堂在线www | 高清免费av | 国产精品爱久久久久久久 | 精品国产一区二区三区四区在线 | 欧美久| 国产成人久久av免费高清密臂 | 亚洲一区日韩 | 91麻豆精品国产91久久久更新资源速度超快 | 国产午夜精品久久久久 | 国产美女视频黄 | 国产一区二区三区在线免费 | 国产精品视频一区二区三区 | 黄色在线播放视频 | 久久久久国产一级毛片 | 久久久成人动漫 | 国产精品看片 | 国产免费a| 亚洲成人在线网 | 欧美福利一区 | 999久久久久久久 | 黄瓜av | 美女亚洲一区 | 国产精品夜间视频香蕉 | 成人免费视频久久 | 精品毛片 | 成人av一区二区三区 | 91视频在线 | 99福利| 国产成人精品一区二区三区视频 | 欧美一级黄色片在线观看 | 日韩在线观看中文字幕 | 中文字幕一区在线观看视频 | 欧美一级免费片 | 亚洲成人观看 | 在线欧美一区 | 91欧美激情一区二区三区成人 | 日韩91 |