Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7308727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:35:53+00:00 2026-05-28T23:35:53+00:00

I’m looking for an action for IntentFilter that is provided while GPS status is

  • 0

I’m looking for an action for IntentFilter that is provided while GPS status is changed. I have found this filter.addAction("android.location.GPS_ENABLED_CHANGE");
but it does not works. I am looking the same thing that I have for bluetooth
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
but for GPS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:35:53+00:00Added an answer on May 28, 2026 at 11:35 pm

    Here is example.

    public class Main extends Activity implements LocationListener {
    
        /* this class implements LocationListener, which listens for both
         * changes in the location of the device and changes in the status
         * of the GPS system.
         * */
    
        static final String tag = "Main"; // for Log
    
        LocationManager lm; 
        StringBuilder sb;
        int noOfFixes = 0;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            /* the location manager is the most vital part it allows access 
             * to location and GPS status services */
            lm = (LocationManager) getSystemService(LOCATION_SERVICE);
        }
    
        @Override
        protected void onResume() {
            /*
             * onResume is is always called after onStart, even if the app hasn't been
             * paused
             * 
             * add location listener and request updates every 1000ms or 10m
             */
            lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 10f, this);
            super.onResume();
        }
    
        @Override
        protected void onPause() {
            /* GPS, as it turns out, consumes battery like crazy */
            lm.removeUpdates(this);
            super.onPause();
        }
    
        @Override
        public void onLocationChanged(Location location) {
            Log.v(tag, "Location Changed");
    
            sb = new StringBuilder(512);
    
            noOfFixes++;
    
            /* display some of the data in the TextView */
    
            sb.append("No. of Fixes: ");
            sb.append(noOfFixes);
            sb.append('\n');
            sb.append('\n');
    
            sb.append("Londitude: ");
            sb.append(location.getLongitude());
            sb.append('\n');
    
            sb.append("Latitude: ");
            sb.append(location.getLatitude());
            sb.append('\n');
    
            sb.append("Altitiude: ");
            sb.append(location.getAltitude());
            sb.append('\n');
    
            sb.append("Accuracy: ");
            sb.append(location.getAccuracy());
            sb.append('\n');
    
            sb.append("Timestamp: ");
            sb.append(location.getTime());
            sb.append('\n');
            Log.v(tag, sb.toString());
        }
    
        @Override
        public void onProviderDisabled(String provider) {
            /* this is called if/when the GPS is disabled in settings */
            Log.v(tag, "Disabled");
    
            /* bring up the GPS settings */
            Intent intent = new Intent(
                    android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
    
        @Override
        public void onProviderEnabled(String provider) {
            Log.v(tag, "Enabled");
            Toast.makeText(this, "GPS Enabled", Toast.LENGTH_SHORT).show();
    
        }
    
        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            /* This is called when the GPS status alters */
            switch (status) {
            case LocationProvider.OUT_OF_SERVICE:
                Log.v(tag, "Status Changed: Out of Service");
                Toast.makeText(this, "Status Changed: Out of Service",
                        Toast.LENGTH_SHORT).show();
                break;
            case LocationProvider.TEMPORARILY_UNAVAILABLE:
                Log.v(tag, "Status Changed: Temporarily Unavailable");
                Toast.makeText(this, "Status Changed: Temporarily Unavailable",
                        Toast.LENGTH_SHORT).show();
                break;
            case LocationProvider.AVAILABLE:
                Log.v(tag, "Status Changed: Available");
                Toast.makeText(this, "Status Changed: Available",
                        Toast.LENGTH_SHORT).show();
                break;
            }
        }
    
        @Override
        protected void onStop() {
            /* may as well just finish since saving the state is not important for this toy app */
            finish();
            super.onStop();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.