estoy creando una aplicación, y para debugarla, me estoy limitando a que cada cierto tiempo me muestre en la UI la fecha y la hora, y ésta se refresque con un while de forma continua.
Mi código (resumido lo máximo) es el siguiente:
Código:
O sea, tv es mi cajita de texto. Y abro un nuevo hilo de la clase Task para que vaya haciendo en background el bucle de actualizar la fecha y mostrarla en la UI.public class MainActivity extends Activity {
private Random r = new Random();
private int i1;
private String fecha;
private String valor;
private Calendar c = Calendar.getInstance();
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private int seconds ;
private TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.logbox);
new Thread(new Task()).start();
}
class Task implements Runnable {
@Override
public void run() {
seconds = c.get(Calendar.SECOND);
while (true){
if ((seconds%15)==0) {
i1 = r.nextInt(80 - 1) + 1;
valor = Integer.toString(i1);
fecha = (sdf.format(c.getTime())).toString();
tv.setText("Fecha: " + fecha + "; Valor: " + valor);
seconds = c.get(Calendar.SECOND);
}
}
}
}
Pues por mucho que acorte el código, me devuelve miles de errores al lanzar la app (que no al compilar). El que más me llama la atención es éste:
Código:
¿alguna ayuda? ¿Puede que esté haciendo algún error garrafal?E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
Gracias!



