Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the answer.</p> <pre><code>import java.util.ArrayList; import org.w3c.dom.Document; import android.app.Dialog; import android.content.Intent; import android.graphics.Color; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMapOptions; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.PolylineOptions; public class GetDirectionsActivity extends FragmentActivity { private String provider; double lati; double longi; String name; GMapV2Direction md; GoogleMap map; Location location; LatLng userLocation, toPosition; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.getdirections); .... new ParseXML().execute(); ..... } private class ParseXML extends AsyncTask&lt;Void, Void, Document&gt; { Document doc; PolylineOptions rectLine; @Override protected Document doInBackground(Void... params) { doc = md.getDocument(userLocation, toPosition, GMapV2Direction.MODE_DRIVING); ArrayList&lt;LatLng&gt; directionPoint = md.getDirection(doc); rectLine = new PolylineOptions().width(3).color( Color.RED); for (int i = 0; i &lt; directionPoint.size(); i++) { rectLine.add(directionPoint.get(i)); } return null; } @Override protected void onPostExecute(Document result) { // TODO Auto-generated method stub map.addPolyline(rectLine); } } } </code></pre> <p>Instead of creating the instance in main class, i created the instance in asynctask for calling the google api.. Rest the Asynctask did.... :)</p>
    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.
    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