Just one thing to note: if you want to interact with the interface
(i.e., changing graphical components), then you'll need to use a
Handler in order to get back on the appropriate thread.


On Aug 6, 4:03 am, Alex Mendez <[email protected]> wrote:
> Thank You, I'll try today
>
> On Aug 5, 8:20 pm, lbcoder <[email protected]> wrote:
>
> > If you want to check something periodically, I suggest using a THREAD,
> > i.e.,
>
> > class AThread extends Thread{
> > public void run(){
> > while (true){
> > //do something
> > sleep(1000);
>
> > }
> > }
> > }
>
> > AThread thread = new AThread();
> > thread.start();
>
> > On Aug 4, 2:49 pm, Alex Mendez <[email protected]> wrote:
>
> > > Hi, I'm new on Android and I just made my first application openning
> > > a
> > > new Activity with a button and some other stuff but now I want to do
> > > something that have to be refreshed every little time or as fast as
> > > possible like a counter.
> > > When you program in C or Java you can make a loop and a counter
> > > adding
> > > 1 so yo can see 1.. 2 .. 3 ...4 .... I would like to be able to do
> > > that when the program is in the foreground. I've tried this code but
> > > it wont even start I get the has stopped unexpectivly when I try to
> > > execute it in the emulator. I also tried with the onStart method and
> > > a
> > > method I made my own and calling it from the onCreate but I get the
> > > same error.
> > >  What I really want to do is to get the sound level in the mic while
> > > the program is running, I have the code for that but I don't know how
> > > to make it check the sound level periodically.
> > > Thank you.
> > > package android.manual1;
> > > import android.app.Activity;
> > > import android.os.Bundle;
> > > import android.view.View;
> > > import android.widget.TextView;
> > > public class Manual1 extends Activity {
> > >     /** Called when the activity is first created. */
> > >     //@Override
> > >     static private int variable = 1;
> > >     public void onCreate(Bundle savedInstanceState) {
> > >         super.onCreate(savedInstanceState);
> > >         setContentView(R.layout.main);
> > >     }
> > >    public void onResume (){
> > >         TextView text = (TextView) findViewById(R.id.count);
> > >         do{
> > >                 text.setText("Contador:"+variable);
> > >                 variable=variable+1;
> > >         }while (variable<100);
> > >     }
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/android-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to