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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:39:25+00:00 2026-05-23T10:39:25+00:00

i want to get latitude and longitude by using gps ..my code is works

  • 0

i want to get latitude and longitude by using gps ..my code is works successfully but it works too slow.
how to get geopoint (latitude and longitude) minimun time duration (20 sec.) ? and how to stop location service or GPS after 30 sec.?

 public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        //Log.i("WHERE","ShowOnMapActivity onCreate()");
        setContentView(R.layout.productlistmapview);

        button_back = (Button)findViewById(R.id.btn_back_map);
        button_back.setOnClickListener(this);


        map_view = (MapView) findViewById(R.id.mapview_productlist);
        LinearLayout zoom_layout = (LinearLayout)findViewById(R.id.zoom_map);  
        View zoomView = map_view.getZoomControls(); 

        zoom_layout.addView(zoomView,new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); 
        map_view.displayZoomControls(true);



        double str_latitude = XMLData.user_latitude;
        double str_longitude =XMLData.user_logitude;

        Log.i("str_latitude",str_latitude+"");
        Log.i("str_longitude",str_longitude+"");


        map_controller = map_view.getController();
;
        double coordinates[] = {str_latitude, str_longitude};
        double lat = coordinates[0];
        double lng = coordinates[1];

        geo_point = new GeoPoint((int) (lat * 1E6),(int) (lng * 1E6));

        map_controller.animateTo(geo_point);
        map_controller.setZoom(9); 



         MapOverlay map_overlay = new MapOverlay();
         List<Overlay> list_of_overlays = map_view.getOverlays();
         list_of_overlays.clear();
         list_of_overlays.add(map_overlay);        

         map_view.invalidate();

    }

    public void onClick(View v)
    {
        switch(v.getId())
        {
         case R.id.btn_back_map:
              Intent back_intent = new Intent(this,GroupPurchasingSelectProduct.class);
              startActivity(back_intent);
              break;    
        }
    }
    @Override
    protected boolean isRouteDisplayed() 
    {
        Log.i("WHERE","ShowOnMapActivity isRouteDisplayed()");
        // TODO Auto-generated method stub
        return false;
    }
    class MapOverlay extends com.google.android.maps.Overlay
    {
        @Override
        public boolean draw(Canvas canvas, MapView mapView, 
        boolean shadow, long when) 
        {
            super.draw(canvas, mapView, shadow);                   

            Point screen_points = new Point();
            mapView.getProjection().toPixels(geo_point, screen_points);


            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pushpin);            
            canvas.drawBitmap(bitmap, screen_points.x, screen_points.y-58, null);         
            return true;
        }
    } 

}
  • 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-23T10:39:25+00:00Added an answer on May 23, 2026 at 10:39 am

    Check this post. This should help you understand how to use location better.

    For stopping the location after 30 seconds you may start a timer and stop the LocationService after that time by calling

     locationManager.stopUpdates(LocationListener).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to get latitude & longitude using the post code with Google
I want to get the base 10 logarithm of a Fixnum using Ruby, but
I want Minimum and Maximum Latitude and Longitude Using Current Location.Suppose i have give
I want to get the Distance between two latitude and longitude in meter /
I want to get location using GPS only. I don't want to use internet
Hai am trying to get the gps location using BroadCast Receiver.its working fine,But i
I am using LocationManager to get the values of Latitude and Longitude of a
I want to find country, city, latitude and longitude from IP address using php.
I managed to get the user's latitude and longitude using HTML-based geolocation. //Check if
I want to get the latitude and longitude on a 3D sphere, depending on

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.