Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the lifecycle of an Activity?
    text
    copied!<p>I am not so clear on how the program in working in Android. I started working on Android for last two months and also I am a beginner in Java. So, I am trying my best to develop and learn. Here is the piece of code I implemented and I am not so clear how it works as per my requirement.</p> <pre><code> activity{ onCreate(){ /* here i am using google maps api and trying to plot the current location*/ OverlayItem overlayItem1 = new OverlayItem(ourLocation,"Our Location","Position"); CustomPinpoint custom1 = new CustomPinpoint(d, Activity.this); custom1.insertPinpoint(overlayItem1); overlayList.add(custom1); controller.animateTo(ourLocation); } private class TouchOverlay extends com.google.android.maps.Overlay{ public boolean onTouchEvent(MotionEvent event, MapView map){ onZoom(); } } public boolean onCreateOptionsMenu(Menu menu){} public boolean onOptionsItemSelected(MenuItem item){ case.X: getGPSPoints();//Here i will be getting some gps points from stored database // and I would like to plot them all on the map. TouchOverlay touchOverlay = new TouchOverlay(); overlayList.add(touchOverlay); } onPause(){ super.onPause(); lm.removeUpdates(this); } onResume(){ super.onResume(); lm.requestLocationUpdates(towers, 500, (float) 0.5, this); } onLocationChanged(Location l) { // TODO Auto-generated method stub clearmap(); lat = (int) (l.getLatitude()*1E6); longi = (int) (l.getLongitude()*1E6); GeoPoint ourLocation = new GeoPoint(lat, longi); CustomPinpoint custom = new CustomPinpoint(d, TrafficMapActivity.this); OverlayItem overlayItem = new OverlayItem(ourLocation,"Our location","Position"); custom.insertPinpoint(overlayItem); overlayList.add(custom); } } </code></pre> <p>My question is when will <code>onLocationChanged</code> method be called and also onTouchEvent method?</p> <p>I have created a method to <code>getGPSPoints()</code> and I would like to plot the obtained points on the map. What my intention is its like google maps traffic layer. I should be continuously drawing when we drag the screen or for zoom in/out. For this I am using the same <code>getGPSPoints</code> method inside <code>onZoom()</code> method in <code>TouchOverlay</code> class.</p> <p>But it is just drawing once when I first selected the option and for the first zoom in/out operation. If I need to draw the remaining I have to click again on the option as per the current implementation. How does this activity works and I should have it?</p>
 

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