02-26-2013 08:27 AM
This is my method for displaying a modal dialog:
public static Dialog handleInactivityDialog(String msg, int[] values) {
Dialog dialogo = new Dialog(msg, new String[] {"Yes", "No"}, values, 2, null);
int i = dialogo.doModal();
if (i == 1){
try{
//do something
Utils.popScreenForLogout();
}catch(Exception e){
Utils.forceLogout();
}
}
return dialogo;
}
After 3 minutes, that dialog must be closed and a new one should be opened. The new dialog should be closed after 1 minute.
I have no idea on how to do this since DIalog.doModal() is a blocking operation.
Thanks in advance!
Solved! Go to Solution.
02-26-2013 08:33 AM
02-26-2013 08:35 AM
Thanks Simon, I have read this answer:
http://stackoverflow.com/a/4348675/1293724
but I don't know how to adapt my code to that suggestion.
02-26-2013 08:44 AM
public static void handleInactivityDialog(String msg, int[] values) {
final Dialog dialogo = new Dialog(msg, new String[] {"Sí", "No"}, values, 2, null);
Timer timer = new Timer();
timer.schedule(new TimerTask(){
public void run()
{
synchronized (UiApplication.getEventLock()) {
int i = dialogo.doModal();
if (i == 1){
try{
//do something
Utils.popScreenForLogout();
}catch(Exception e){
Utils.forceLogout();
}
}
}
}
}, 60*1000);
}
In case this is fine, where should I add the dialog.close() ?
02-26-2013 08:48 AM
02-26-2013 08:59 AM
Ok, thanks Simon. This way works:
public static void handleInactivityDialog(String msg, int[] values) {
final Dialog dialogo = new Dialog(msg, new String[] {"Sí", "No"}, values, 2, null);
Timer timer = new Timer();
timer.schedule(new TimerTask(){
public void run()
{
synchronized (UiApplication.getEventLock()) {
dialogo.close();
}
}
}, 60*1000);
int i = dialogo.doModal();
if (i == 1){
try{
CommManager.doLogout();
Utils.popScreenForLogout();
}catch(Exception e){
Utils.forceLogout();
}
}
}