Buenas, no consigo comprender porque tras ejecutarse el método onCheckedChanged() no me cambia el valor de la variable... Gracias un saludo.
Código Java:
Ver originalpackage juan.pruebas.smssender;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Toast;
public class GNOCAccesSmsSenderActivity extends Activity {
/** Called when the activity is first created. */
String telefonoGnoc
="605097654"; public String entradaSalida
= "";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final CheckBox checkBox = (CheckBox)findViewById(R.id.checkBoxEntradaSalida);
EditText numCaso = (EditText)findViewById(R.id.numCaso);
EditText emplazamiento = (EditText)findViewById(R.id.emplazamiento);
EditText nomTec = (EditText)findViewById(R.id.nomTec);
EditText empresa = (EditText)findViewById(R.id.empresa);
EditText trabRealizar = (EditText)findViewById(R.id.trabRealizar);
String var_numCaso
= numCaso.
getText().
toString(); String var_emplazamiento
= emplazamiento.
getText().
toString(); String var_nomTec
= nomTec.
getText().
toString(); String var_empresa
= empresa.
getText().
toString(); String var_trabRealizar
= trabRealizar.
getText().
toString();
Button botonEnvioSms
= (Button)findViewById
(R.
id.
botonEnvioSms);
if (checkBox.isChecked()){
checkBox.setChecked(false);
}
checkBox.setOnCheckedChangeListener(new android.widget.CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if (checkBox.isChecked()){
checkBox.setText("Entrada");
entradaSalida = "INI.";
} else {
checkBox.setText("Salida");
entradaSalida = "FIN.";
}
}
});
final String sms
= entradaSalida
+ "." + var_numCaso
+ "." + var_emplazamiento
+ "." + var_nomTec + "." + var_empresa + ".LOC:IN-" + var_trabRealizar;
final SmsManager enviarSms = SmsManager.getDefault();
String DELIVERED
= "SMS_DELIVERED"; final PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
final PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
botonEnvioSms.
setOnClickListener(new View.
OnClickListener() {
public void onClick
(View v
) { // TODO Auto-generated method stub
//enviarSms.sendTextMessage(telefonoGnoc, null, sms, sentPI, deliveredPI);
Toast.makeText(getApplicationContext(), sms, Toast.LENGTH_LONG).show();
}
});
}
}