Hi, i have 2 questions about widgets update
I have 2 buttons and i need to change one button text when i press the other one, how can i do this?
The first time i open the widget it calls the onUpdate method, but it never calls it again. I need to update the widget every 2 seconds and i have this line in the xml.
android:updatePeriodMillis="2000"
Do i need a service or should it works just with the updatePeriodMillis tag?
onUpdate method
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.newswidget);
Intent intent = new Intent(context, DetalleConsulta.class);
intent.putExtra(DetalleConsulta.CONSULTA_ID_NAME, "3");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
views.setOnClickPendingIntent(R.id.btNews, pendingIntent);
/* Inicializa variables para llamar el controlador */
this.imei = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
this.controlador = new Controlador(this.imei);
try {
this.respuestas = this.controlador.recuperarNuevasRespuestas();
if(this.respuestas != null && this.respuestas.size() > 0){
Iterator<Consulta> iterRespuestas = this.respuestas.iterator();
views.setTextViewText(R.id.btNews, ((Consulta)iterRespuestas.next()).getRespuesta());
}
} catch (PersistenciaException e) {
//TODO manejar error
}
appWidgetManager.updateAppWidget(appWidgetIds, views);
thx a lot!!!