Note that there are some explanatory texts on larger screens.

plurals
  1. POSaving Long and Latitute to String - Parsing String to Google Maps
    primarykey
    data
    text
    <p>I'm trying to do the following.</p> <p>-Get the long and latitude stored as a String that I can</p> <p>-Insert into a clickable URL that opens Google Maps (ie <a href="http://maps.google.com/long=string1+lat=string2" rel="nofollow">http://maps.google.com/long=string1+lat=string2</a>) - this URL is included in an email that is being sent through the default email app.</p> <p>I've tried looking at URI, Linkify, Reverse GeoCoding but I can't seem to get anything. I can get the co-ords and display as a Toast notification, but trying to save them to use elsewhere is problematic at the moment.</p> <p>I've string String lat = Double.toString(location.getLatitude) but didn't get anything from it, or maybe there was no co-ords to get at the time the code executed as it perhaps didn't have a GPS lock, not too sure. Please see code below.</p> <p>public class ConfirmScreen extends Activity{</p> <pre><code>String mapCoord = "http://maps.google.com"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_confirm_screen); LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); LocationListener mLocListener = new MyLocationListener(); mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0, mLocListener); sendEmail(); playSound(); } public void backHome(View view) { Intent intent = new Intent (this, MainScreen.class); startActivity(intent); } // Method to start playing and looping a sound. public void playSound() { MediaPlayer clickSound = MediaPlayer.create(this, R.raw.warning); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); Boolean soundCheck = sp.getBoolean("SOUND", false); if (soundCheck) { clickSound.start(); } }// method end public void sendEmail() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); String nameValue = sp.getString("NAME", "failed to get name"); String emailValue = sp.getString("EMAIL", "failed to get email"); Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[]{emailValue}); i.putExtra(Intent.EXTRA_SUBJECT, "Email sent from DON'T PANIC - A Chris O'Brien Project"); i.putExtra(Intent.EXTRA_TEXT, "Hi there\n" + nameValue + " is in mortal danger. Please see the co-ords attached and run to their rescue!" + " If you don't see any co-ords, they didn't check the box and assume you know where they are.\nKind Regards\nDon't Panic! \n\n" + mapCoord); try { startActivity(Intent.createChooser(i, "Send mail....")); } catch (android.content.ActivityNotFoundException ex){ Toast.makeText(ConfirmScreen.this, "There are no email clients installed or set up", Toast.LENGTH_SHORT).show(); } } //Location Listener public class MyLocationListener implements LocationListener { @Override public void onLocationChanged(Location location) { location.getLatitude(); location.getLongitude(); String text = "Current Location is \nLat: " + location.getLatitude() + " \nLng: " + location.getLongitude(); //mapCoord = Double.toString(location.getLatitude()) + " " + Double.toString(location.getLongitude()); Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } @Override public void onProviderDisabled(String provider) { Toast.makeText(getApplicationContext(), "GPS Disabled", Toast.LENGTH_SHORT).show(); } @Override public void onProviderEnabled(String provider) { Toast.makeText(getApplicationContext(), "GPS Enabled", Toast.LENGTH_SHORT).show(); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_confirm_screen, menu); return true; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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