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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:48:46+00:00 2026-06-12T02:48:46+00:00

I have a MapActivity which has a touch event. In the touch event: I

  • 0

I have a MapActivity which has a touch event.

In the touch event:

  • I get the current geocodes

  • Put an overlay image on that location.

  • and set it as the center of the mapview.

This seems to work fine and as expected for a while. But then the application force closes. I think the touch event is being fired like crazy even when nothing’s being touched. I know that because I had put a toast set up that shows the longitude and lattitude of the touched position. and it keeps showing up even when nothing’s touched.

I cant seem to accurately position the problem, let alone fixing it. Here’s the touch event for my mapActivity

private void LocationStuffs(double latitude, double longitude){
    itemizedOverlay.clear();
    itemizedOverlay.addOverlayItem((int)latitude, (int)longitude, "place"); 
    mapView.invalidate();
    mapView.getOverlays().add(itemizedOverlay);
    MapController mc = mapView.getController();
    mc.setCenter(new GeoPoint((int)latitude, (int)longitude)); 
    mc.setZoom(20);
}

public boolean onTouchEvent(MotionEvent event, MapView mapView){
        //---when user lifts his finger---
        if (event.getAction() == 1) {
            GeoPoint p = mapView.getProjection().fromPixels(
                    (int) event.getX(),
                    (int) event.getY());
            Toast.makeText(getBaseContext(),
                    p.getLatitudeE6() / 1E6 + "," +
                            p.getLongitudeE6() /1E6 ,
                            Toast.LENGTH_SHORT).show();
            latitude = p.getLatitudeE6() / 1E6;
            longitude = p.getLongitudeE6() / 1E6;
            LocationStuffs(latitude*1E6, longitude*1E6);
        }
        return false;
    }
  • 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-12T02:48:47+00:00Added an answer on June 12, 2026 at 2:48 am

    Change your return statement to return true:

    return true;
    

    Basically, what that does is that it tells the system that you have handled the touchevent. Let me know if that solves it.

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

Sidebar

Related Questions

I have written one MapActivity class that is able to display a set of
I have a Tab that has a custom layout which contains a TextView .
I have a View in Android that has an onTouchEvent which stores the x
I've a layout now, which has a add location button. The current layout is
Below is my class which draws an image on the current location on the
I have set up a MapView Class which has Overlays (and they're working fine.)
I have an Android Application that has the AndroidManifest.xml listed below. After uploading to
I have one activity 'A' which extends mapActivity which calls service 'B', and Service
I have built an android application which has a single mapview. I have a
I have an Activity which extends MapActivity (to show a MapView) and contains a

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.