Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>private class LocationControl extends AsyncTask&lt;Context, Void, Void&gt; { private final ProgressDialog dialog = new ProgressDialog(MainActivity.this); protected void onPreExecute() { this.dialog.setMessage("Tap outside dialog to close"); this.dialog.setTitle("Searching your current location..."); //this.dialog.setTitle(R.string.hello); this.dialog.setCanceledOnTouchOutside(true); this.dialog.show(); } protected Void doInBackground(Context... params) { //Wait 40 seconds to see if we can get a location from either network or GPS, otherwise stop Long t = Calendar.getInstance().getTimeInMillis(); while (!hasLocation &amp;&amp; Calendar.getInstance().getTimeInMillis() - t &lt; 40000) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } }; return null; } protected void onPostExecute(final Void unused) { if(this.dialog.isShowing()) { this.dialog.dismiss(); } if (currentLocation != null) { GeoPoint startPoint = new GeoPoint((int)(currentLocation.getLatitude()*1E6),(int)(currentLocation.getLongitude()*1E6)); final MapController mc = mapView.getController(); mc.animateTo(startPoint); mc.setZoom(16); } else { /* Toast.makeText(MainActivity.this, "Location could not be found\nusing default location", Toast.LENGTH_SHORT).show(); GeoPoint startPoint = new GeoPoint((int)(43.332628*1E6),(int)(5.353128*1E6)); final MapController mc = mapView.getController(); mc.animateTo(startPoint); mc.setZoom(16); */ } } } </code></pre> <p>And call the execute from your <code>onCreate()</code>:</p> <pre><code>locationControlTask = new LocationControl(); locationControlTask.execute(this); </code></pre>
    singulars
    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