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 7034361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:10:36+00:00 2026-05-28T01:10:36+00:00

i have to get my location inside service from another class by this code

  • 0

i have to get my location inside service from another class by this code

      Mylocation mylol = new Mylocation();
    private void locationClick() {




         mylol.getLocation(this, locationResult);


                            mylol.cancelTimer();

         // runDialog(3);

    }

    public LocationResult locationResult = new LocationResult(){
    ;
        @Override
        public void gotLocation(final Location location){
            //Got the location!
            double MyFinalLat=location.getLatitude();
            double MyFinalLon=location.getLongitude();
            Myloc=MyFinalLat+","+MyFinalLon;
            Toast.makeText(getBaseContext(),"Your current location"+Myloc,
                    Toast.LENGTH_SHORT).show();
            };
        };

}

but i should make the gpss take his time to find locattion
how can i make my service slaaps for 20 secons for exampl??

  • 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-28T01:10:36+00:00Added an answer on May 28, 2026 at 1:10 am

    The code:

    Thread.sleep(20000);
    

    Will make the current thread sleep for 20 seconds. From an Activity, this would probably cause a force close, because it effectively make your process seem like it’s locked up (I assume). In a Service, as you describe, you may be alright though.

    BTW the 20 seconds isn’t incredibly precise, as noted in the docs.

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

Sidebar

Related Questions

I have a requirement in a shell script. I get this location information from
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor
Inside public class IAmHere extends Activity implements LocationListener { i have @Override public void
I have put fancybox (jquery plugin ) inside the assets/javascripts/includes/jquery.fancybox-1.3.4 Before this location i
Inside of a class called Castle I have the following 2 functions: vector<Location> Castle::getMoves(Location***
I have my current location fixed via CoreLocation. Now I want to get those
So I have a class that has the following member variables. I have get
I have to get records from my MySQL DB where: sentto = $username OR
I have some images inside links that I want to essentially look like this:
I have this unit test: [Test] public void ProcessDbFile_should_delete_file_if_it_exists_then_copy_new_file_to_same_location() { // used to create

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.