Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to speak current latitude,longitude text into speech
    primarykey
    data
    text
    <p>I want to convert my current latitude,longitude text into speech.I have code for finding current latitude,longitude.But i initialize the TextToSpeech method inside Location class i got only latLongString.I couldn't get EX:your current location is lat=1.222,long=22.335.</p> <p>Here my Code:</p> <pre><code>public class SpeakActivity extends Activity implements OnInitListener{ private TextToSpeech tts; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_speak); LocationManager locationManager; String context = Context.LOCATION_SERVICE; locationManager = (LocationManager)getSystemService(context); Criteria crta = new Criteria(); crta.setAccuracy(Criteria.ACCURACY_FINE); crta.setAltitudeRequired(false); crta.setBearingRequired(false); crta.setCostAllowed(true); crta.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(crta, true); // String provider = LocationManager.GPS_PROVIDER; Location location = locationManager.getLastKnownLocation(provider); tts = new TextToSpeech(this, this); updateWithNewLocation(location); } public void speak(String text2say){ tts.speak(text2say, TextToSpeech.QUEUE_FLUSH, null); } @Override public void onInit(int status) { say("latLongString"); } private void updateWithNewLocation(Location location) { String latLongString; TextView myLocation; myLocation= (TextView) findViewById(R.id.myLocation); if(location!=null) { double lat = location.getLatitude(); double lon = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lon; }else{ latLongString="no location found"; } myLocation.setText("Your current position is:\n" + latLongString); speak(latLongString); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_speak, menu); return true; } @Override public void onDestroy() { if (tts!= null) { tts.stop(); tts.shutdown(); } super.onDestroy(); }} </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.
 

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