久久久久久久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 已啟用,但永遠(yuǎn)不會

      LocationListener of NETWORK_PROVIDER is enabled but , onLocationChanged is never called(NETWORK_PROVIDER 的 LocationListener 已啟用,但永遠(yuǎn)不會調(diào)用 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 已啟用,但永遠(yuǎn)不會調(diào)用 onLocationChanged的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我正在開發(fā)一個應(yīng)用程序,該應(yīng)用程序可以在服務(wù)中的 6 分鐘和 6 分鐘內(nèi)全天獲取手機的位置,它工作正常,但有時網(wǎng)絡(luò)提供商偵聽器的方法 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.

                它由于某種原因停止被調(diào)用,但是提供程序已啟用并且列表器正在工作,當(dāng)我手動啟用或禁用提供程序時,會調(diào)用 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.

                這只是發(fā)生在 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:

                仍然連續(xù) 4 天收到Sem sinal".

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

                Galaxy Y 和 LG Optimus l5 已經(jīng)出現(xiàn)此問題

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

                我進(jìn)行了另一項測試,看看其他應(yīng)用程序是否獲得了 NET 位置,我發(fā)現(xiàn)它們通過了同樣的問題,它們無法僅通過 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 聽眾停止給出位置,但這可能是因為它不應(yīng)該連續(xù)工作 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.

                我已經(jīng)對其他應(yīng)用程序進(jìn)行了一些測試,看看這個問題是否只是在我的應(yīng)用程序中發(fā)生,我發(fā)現(xiàn)它們正在通過同樣的問題,例如在 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 提供程序,出現(xiàn)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:

                但是當(dāng)我打開谷歌地圖時,它似乎工作正常,我試圖移動到一個較遠(yuǎn)的地方,看看它是否會顯示 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 遇到過類似的問題,唯一的解決方案是強制設(shè)備重啟.盡管谷歌地圖總是顯示正確的位置,因為它使用了除了網(wǎng)絡(luò)位置提供者之外的其他傳感器信息.

                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 服務(wù)框架,比 GPS/網(wǎng)絡(luò)位置提供商超級好用.

                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,現(xiàn)在當(dāng)我遇到網(wǎng)絡(luò)提供商這個奇怪的問題時,同時融合位置給了我準(zhǔn)確的位置(無需重啟設(shè)備).

                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).

                我已經(jīng)提交了一個工作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;
                    }
                }
                

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

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

                相關(guān)文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經(jīng)度計算 X 和 Y)
                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                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 返回負(fù)速度)
                How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)

                    <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>
                          主站蜘蛛池模板: 毛片一级片 | 韩日一区 | 亚洲精品日本 | 久久精品亚洲欧美日韩精品中文字幕 | 亚洲精品久久久9婷婷中文字幕 | 一级毛片视频在线 | 中文字幕高清av | 欧美日韩精品在线一区 | 日韩视频一区二区三区 | 精品一区二区三区电影 | 国产亚洲精品精品国产亚洲综合 | 久久99精品久久久久久 | 91丨国产| 九九久久国产 | 亚洲国产成人精品久久久国产成人一区 | 日本三级播放 | 日韩网| 91国产精品在线 | 国产视频久| 亚洲精品1区| 精品自拍视频 | 国产精品日女人 | 欧美精品中文字幕久久二区 | 国产日韩亚洲欧美 | 91香蕉 | 欧美一级做性受免费大片免费 | 成人午夜激情 | 亚洲午夜精品在线观看 | 一级免费黄色 | 日韩精品免费视频 | 97视频在线看 | 日韩精品亚洲专区在线观看 | 成人在线中文字幕 | 成年人网站在线观看视频 | 日本一二三区电影 | 久久久久国产精品一区三寸 | 国产在线观看一区二区三区 | 亚洲欧美在线视频 | 亚洲国产精品激情在线观看 | 欧美精品在线一区二区三区 | 精品在线99 |