How to set activity to be active all the time?
<p>I have activity which needs to be active all the time. I have thread which sleep 10 sec, and monitors values taken from database, compare them and start method. I'm wondering if user go back to other applications and activities, does my activity and thread still work, or they are handled by activity manager and go to pause-stop-destroy?? How to stay them a live??
Thank you.
here is code for that thread:</p>

<pre><code> new Thread(new Runnable() {

        public void run() {
            // TODO Auto-generated method stub
            while(true){
                try {
                    Thread.sleep(10000);
                    myHendler.post(new Runnable() {

                        public void run() {
                            // TODO Auto-generated method stub

                            final Calendar cal = Calendar.getInstance();
                            int godina2 = cal.get(Calendar.YEAR);
                            int mesec2 = cal.get(Calendar.MONTH);
                            int dan2 = cal.get(Calendar.DAY_OF_MONTH);
                            int sati2 = cal.get(Calendar.HOUR_OF_DAY);
                            int minuti2 = cal.get(Calendar.MINUTE);

                            trenutniDatum = new StringBuilder().append(dan2).append("-").append(mesec2 +1).append("-").append(godina2);
                            trenutnoVreme = prepraviVreme(sati2) + ":" + prepraviVreme(minuti2);
                            for(int i = 0; i &lt; primljenoIzBazeDatum.length; i++){
                                String bazaBroj = "";
                                String bazaText = "";
                                if(primljenoIzBazeDatum[i].toString().equals(trenutniDatum.toString()) &amp;&amp; primljenoIzBazeVreme[i].toString().equals(trenutnoVreme)){

                                        int bazaId = Integer.parseInt(primljenoIzBazeId[i]);
                                        bazaBroj = primljenoIzBazeBroj[i].toString();
                                        bazaText = primljenoIzBazeText[i].toString();
                                        String datumPromena = "*" + primljenoIzBazeDatum[i].toString() + "* SENT *";

                                        datumVreme.open();
                                        datumVreme.updateData(bazaId, datumPromena);
                                        datumVreme.close();

                                        sendPoruka(bazaBroj, bazaText);

                                }

                            } // end for


                        } // end run
                    });
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }).start();
</code></pre>
