Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I used location manager for change status of GPS in navigation app. But it not working in android 10 (samsung a10). Unfortunately broadcast receiver is limited in android 10.

My code is:

locationManager.addGpsStatusListener(new GpsStatus.Listener() {
            @Override
            public void onGpsStatusChanged(int event) {
                switch (event) {
                    case GpsStatus.GPS_EVENT_STARTED:
                        Log.i(TAG, "GpsStatusChanged started");
                        break;
                    case GpsStatus.GPS_EVENT_STOPPED:
                        Log.i(TAG, "GpsStatusChanged stopped");
                        break;
                    case GpsStatus.GPS_EVENT_FIRST_FIX:
                        break;
                    case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                        break;

How to resolve it?

Thanks for your help...

addGpsStatusListener is deprecated in API level 24. Please use LocationManager.registerGnssStatusCallback(GnssStatus.Callback) instead.

More info, go to the documentation

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.