Problem Using ScheduledThreadPoolExecutor

Discussion in 'Android Tablet Discussions' started by Ya2, Aug 1, 2011.

  1. Ya2

    Ya2 Member

    Jun 27, 2011
    Likes Received:
    Trophy Points:
    I'm coding a program which calls a servlet, gets Strings in return, and posts the Strings into an EditText.

    The code works fine without using the ScheduledThreadPoolExecutor , but when I use it, debugging the servlet shows the request has arrived, and it returns a answer, yet the Android application never posts the String into the EditText.

    I want the program to call the servlet every 1 second.
    At the moment where the program needs to start polling, this code is activated:

    Class data member :

    private ScheduledThreadPoolExecutor timer = new ScheduledThreadPoolExecutor(1);

    Code in class :

    timer.scheduleAtFixedRate(new Runnable() {
    public void run() {
    try {
    String[] recentEvents;
    recentEvents = getAllEvents(); // Gets the strings from the servlet
    if (recentEvents != null)
    activateEvents(recentEvents); // Prints them to the EditText
    } catch (IOException e) {
    }, 100, 1000,TimeUnit.MILLISECONDS);

Share This Page

Search tags for this page

android scheduledthreadpoolexecutor


scheduledthreadpoolexecutor android