Note that there are some explanatory texts on larger screens.

plurals
  1. POBlackberry service thread hangs the ui when executing
    text
    copied!<p>In my blackberry app i am using alternate entry point and run a thread on startup which does http operation and the same thread is called repeatedly after some time lets say 3 minutes. It does its operation but the problem is it hangs the ui here is my code.</p> <pre><code>final class sendUnsentService extends Thread { Timer timer; TimerTask repeatMe; sendUnsentService me; boolean working = false; public boolean isWorking() { return working; } public void interrupt() { super.interrupt(); System.out.println("___________________________[STOPSERVICE()]"); try { timer.cancel(); } catch (Exception e) { System.out .println("_______________________[PROBLEM STOPPING SERVICE]"); } } public void run() { super.run(); System.out.println("___________________________[STARTSERVICE()]"); new Thread() { public void run() { timer.schedule(repeatMe, 0, 300000); }; }.start(); } public sendUnsentService() { me = this; ImageUtils.initPersistentStorage(); timer = new Timer(); repeatMe = new TimerTask() { public void run() { working = true; if (sendUnsentActivity()) { me.interrupt(); } working = false; } }; } </code></pre> <p>I am invoking this thread on some user interaction using this code and then it hangs the ui</p> <pre><code>try { helloBerry.service = new sendUnsentService(); } catch (Exception e) { System.out.println("_____________1 " + e); } try { helloBerry.service.startService(); } catch (Exception e) { System.out.println("_____________2 " + e); } </code></pre> <p>and this is how i call the service to start on device booting in main method using alternate entry point</p> <pre><code>if (args != null &amp;&amp; args.length &gt; 0 &amp;&amp; args[0].equals("normal")) { System.out.println("_________[STARTING APP]"); ___________some code here to show a screen } } else { System.out.println("_________[STARTING SERVICE]"); service = new sendUnsentService(); service.run(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload