ok, obrigado pelas dicas, estou começando a me aprofundar no android...
abs...
--
Atenciosamente,
Luís Gustavo Verri Zacheu
luiszacheu@gmail.com
Em 6 de dezembro de 2011 11:10, Matheus Bodo <mcbodo@gmail.com> escreveu:
Bom, eu ainda não tentei rodar seu código, mas duas sugestões são:
-Dê uma conferida no Logcat, ele pode estar indicando qual o problema.
-Tente usar o debug e ver o que as chamadas location.getLatitude() e location.getLongitude() estão retornando.
[]s--On Tue, Dec 6, 2011 at 10:12 AM, Luis Gustavo Verri Zacheu <luiszacheu@gmail.com> wrote:
Então na verdade nao verifiquei o logcat, porem eu queria que aparecesse nos edittext os valores da longitude e latitude porem não aparece.Fiz a conversão de doble pra string, pois o getLatidute e getLongitude retornam double correto?--2011/12/6 Matheus Bodo <mcbodo@gmail.com>Olá Luis,
Qual o erro que está dando? Aparece algo no Logcat?
Você adicionou a permissão ACCESS_FINE_LOCATION no AndroidManifest.xml?
[]s--On Mon, Dec 5, 2011 at 4:18 PM, luiszacheu <luiszacheu@gmail.com> wrote:
Olá a todos, estou tentando montar uma app que pegue os valores de
latitude e longitude e quando acionado um evento em um buttun atribua
esses valores em edittexts.
abaixo o codigo que eu estou fazendo, alguem sabe me dizer em que
estou errando?
public class principal extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btGetLocation = (Button)
findViewById(R.id.btGetLocation);
btGetLocation.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
// AndroidManifest.xml must have the
following permission:
// <uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>
LocationManager locationManager =
(LocationManager)
getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0, 0, new LocationListener() {
public void
onStatusChanged(String provider, int status, Bundle
extras) {
// called when the
provider status changes. Possible status:
OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE or AVAILABLE.
}
public void
onProviderEnabled(String provider) {
// called when the
provider is enabled by the user
}
public void
onProviderDisabled(String provider) {
// called when the
provider is disabled by the user, if it's
already disabled, it's called immediately after
requestLocationUpdates
}
public void
onLocationChanged(Location location) {
//double latitute =
location.getLatitude();
//double longitude =
location.getLongitude();
// do whatever you
want with the coordinates
EditText x =
(EditText) findViewById(R.id.edLocationX);
EditText y =
(EditText) findViewById(R.id.edLocationY);
x.setText(String.valueOf(location.getLatitude()));
y.setText(String.valueOf(location.getLongitude()));
}
});
}
});
}
Matheus Augusto Bodo
Atenciosamente,
Luís Gustavo Verri Zacheu
luiszacheu@gmail.com
Matheus Augusto Bodo
Atenciosamente,
Luís Gustavo Verri Zacheu
luiszacheu@gmail.com
http://www.linkedin.com/in/luiszacheu
+55 (43) 9920-9645
+55 (43) 9920-9645






0 comentários:
Postar um comentário