Note that there are some explanatory texts on larger screens.

plurals
  1. POsend message from Mapview.draw to activity
    primarykey
    data
    text
    <p>I want to get the screen center when the map finally stops moving after a fling. I notice that there is no standard SDK event for this. I have seen a few techniques such as <a href="https://stackoverflow.com/questions/1773717/android-maps-how-to-determine-map-center-after-a-drag-has-been-completed">override MapView.onTouchEvent</a>, or start a repeating timer on ACTION_UP and wait for end of map movement.</p> <p>I am looking at overriding MapView.draw :-</p> <pre><code>@Override public void draw(Canvas canvas) { super.draw(canvas); Log.e(TAG, "draw"); center = this.getMapCenter(); //(GeoPoint) if (centerSave != null){ if (centerSave.equals(center)){ Log.e(TAG, "map stopped moving"); // Now what goes here????? } } centerSave = center; } </code></pre> <p>This "fling end" detection is a bit simpler then the others I have seen but it does maybe load the CPU a bit more since it runs on every draw.</p> <p>I now want to send some kind of message/event to my MapActivity saying that the map has stopped moving. The MapActivity will then put a pushpin at the map center.</p> <p>How do I send this message?</p> <p>It is not messageing between threads, but between 2 different classes. There is probably a simple technique but the trick is to know it.</p> <p>Thanks for any help</p> <p>Peter</p> <p>EDIT: I am using a handler to send a message to the UI thread. Unfortunately it is not solving the fling issue, (but it is an improvement).</p> <pre><code>// Now what goes here???? Message m = Message.obtain(); m.what = MyApplication.HANDLE_DRAW_TO; MyApplication.tabbedMapActivityHandler.dispatchMessage(m); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload