English 中文(简体)
即便在大楼内,为何提供(......)方法总是真实返回
原标题:Why isProviderEnabled() method always return true even inside the Building
  • 时间:2012-05-02 10:35:01
  •  标签:
  • android
  • gps

在此情况下,我使用全球定位系统作为供应商,试图在大楼内行走,但似乎与它一样没有找到地点。 Yeah认为,在建筑中,全球定位系统不可行。 因此,为什么让人们能够返回? 不管怎么说,“对全球定位系统信号的排序”应当如何实施?

            String context = Context.LOCATION_SERVICE;
            locman = (LocationManager)getSystemService(context);


            Criteria criteria = new Criteria();
            criteria.setAccuracy(Criteria.ACCURACY_FINE);
            criteria.setAltitudeRequired(false);
            criteria.setBearingRequired(false);
            criteria.setPowerRequirement(Criteria.POWER_LOW);
            String provider = locman.getBestProvider(criteria, true);

            if (locman.isProviderEnabled( LocationManager.GPS_PROVIDER )) {
            // Change from  Searching for GPS signal to Use GPS 
                txtGPS.setText("Use GPS");

            }
            locman.requestLocationUpdates(
                    provider,MIN_TIME, MIN_DISTANCE, locationListener);
最佳回答

isProviderEnabled(>>, 仅看你是否使全球定位系统得以运行,如果你看到任何卫星,则只看看看看看管。

If you like to check, if there are any satellites you have to use the gpslistener and this is how to use the gpslistner:

/**
         * Hier wird ein neuer GPSListener erstellt.
         * Dieser Überprüft ob es Sichtbare Sattelitten gibt.
         */
        mLocationManager.addGpsStatusListener(new GpsStatus.Listener() {

            public void onGpsStatusChanged(int event) {

                // Hier wird der EVENT gefiltert
                // Dieser EVENT erscheint immer wenn GPS Satteliten in sicht sind
                if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
                    // GpsStatus casten
                    GpsStatus status = mLocationManager.getGpsStatus(null);

                    // Interable sats instanzieren und casten
                    Iterable<GpsSatellite> sats = status.getSatellites();

                    // SATCOUNT instanzieren, wird benötigt um die Satteliten zu zählen
                    int SATCOUNT = 0;

                    // Interator satI instanzieren und casten.
                    Iterator<GpsSatellite> satI = sats.iterator();

                    // Hier wird die anzahl der Satteliten gezählt
                    while(satI.hasNext()){
                        // Den Interator auf den nächsten Satteliten verweisen
                        GpsSatellite satellite = satI.next();

                        // Satelitten zählen
                        SATCOUNT++;
                        Log.d("GPSListner", "While with SATCOUNT = " + SATCOUNT + " Elevation des Satellites = " + satellite.getElevation());


                    }

                    // Prüfen ob SATCOUNT 4 Satelitten hat
                    if(SATCOUNT > GPS_SAT_COUNT){

                    String test = String.valueOf(SATCOUNT);
                    Log.d("GPSSTATUS", "(true) Anzahl der Sattelitten: " + test );

                    // Boolean mGpsOk auf true setzen
                    GPSService.mGpsOk = true;
                    }else{

                    String test2 = String.valueOf(SATCOUNT);
                    Log.d("GPSSTATUS", "(fasle) Anzahl der Sattelitten: " + test2 );

                    // Boolean mGpsOk auf false setzen
                    GPSService.mGpsOk = false;

                    }

                }
            }
        });

为了做到这一点,你需要开始一个希望使用ps块的地点群,现在,如果看上去有卫星并写出一个可变的真实或虚假的卫星,那么你就能够检查。 之后,你可以检查Variabel。 如果其真实性(至少4颗卫星观测)能使用<代码> 标准。 CCURACY_FINE 页: 1 标准。 CCURACY_COARSE. 不要忘记为双方提供许可!

最佳方面

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签