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

  • Home
  • SEARCH
  • 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 9267051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:27:35+00:00 2026-06-18T14:27:35+00:00

I have used the code to to play mp3 sound after 30 secs interval

  • 0

I have used the code to to play mp3 sound after 30 secs interval and 30 mts distance but it does not play after the mobile is sleeping and I have travelled well over 5 miles.

HOW to make the code above work ?
Please Help.

Thanks in Advance.

I had an addon query : Does onLocationChanged method know my last location? In other words if I have executed this statement :

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30, 30000, new MyLocationListener());

Will mp3 file execute every 30 secs interval and 30 mts distance by itself? OR will I have to execute the statement within ScheduledExecutorService like this:

ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
        executor.scheduleWithFixedDelay(new Runnable(){

            public void run() {

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30, 30000, new MyLocationListener());



            }

        }, 0, 600, TimeUnit.SECONDS);

Total Code :

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30, 30000, new MyLocationListener());





private class MyLocationListener implements LocationListener {


    public void onLocationChanged(Location location) {


        ///Audio file which plays everytime the above condition is met 
        mp3.start();



        );

        Toast.makeText(AndroidGPSSampleActivity.this, message, Toast.LENGTH_LONG).show();
    }

    public void onStatusChanged(String s, int i, Bundle b) {

        Toast.makeText(AndroidGPSSampleActivity.this, "Provider status changed",Toast.LENGTH_LONG).show();
    }

    public void onProviderDisabled(String s) {

        Toast.makeText(AndroidGPSSampleActivity.this,"Provider disabled by the user. GPS turned off",Toast.LENGTH_LONG).show();
    }

    public void onProviderEnabled(String s) {
        System.out.println("==onProviderEnabled=" + s);
        Toast.makeText(AndroidGPSSampleActivity.this, "Provider enabled by the user. GPS turned on",Toast.LENGTH_LONG).show();
    }


}
  • 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-06-18T14:27:36+00:00Added an answer on June 18, 2026 at 2:27 pm

    First I think you need to check that your location parameters are what you meant. Your time of 30 actually means 30 milliseconds, I think you want 30 * 1000. Your distance is 30000 meters, which is around 18 miles. So I don’t think you wanted 30000, but 30 instead.

    Now, you will only be notified according to those parameters if the location actually changes. So if in 30 seconds the location is the same or within 30 meters of the last position you won’t get notified. In addition you are using the network provider which in the best case where you have a wifi location your accuracy is 60 meters which means you may have to move quite a bit more before you get notified. If you are getting cell tower locations you may be going a long way before it switches cell towers, and hence locations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have few short sound effect samples, which play just fine in emulator, but not
I have used this code for extracting urls from web page.But in the line
I am not very experienced with rails, but I have used it for several
I have code that is currently 'open source' but not easily accessible since it
I have not changed my code, which used to work, I even clarified this
I have used the code from apples example from this page: Link , but
Does anyone know of some mp3 playing code for the pocket PC. I have
Here is the code i am using.I have used Clip class to play a
I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
I have used this code (kind of tutorial) at http://code.google.com/p/gwt-examples/wiki/gwt_hmtl5 ... In this code,

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.