Hello and thanks for the reply,
It's really the user abortable loop that I'm having trouble with now.
Since first posting my problem, I have been researching code snippets and
have zeroed in on this one:
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class DelayTimer extends Activity {
TextView mTextField;
long elapsed;
final static long INTERVAL=1000;
final static long TIMEOUT=5000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTextField=(TextView)findViewById(R.id.textview1);
TimerTask task=new TimerTask(){
@Override
public void run() {
elapsed += INTERVAL;
if(elapsed >= TIMEOUT){
this.cancel();
displayText("finished");
return;
}
//if(some other conditions)
// this.cancel();
displayText("seconds elapsed: " + elapsed / 1000);
}
};
Timer timer = new Timer();
timer.scheduleAtFixedRate(task, INTERVAL, INTERVAL);
}
private void displayText(final String text){
this.runOnUiThread(new Runnable(){
@Override
public void run() {
mTextField.setText(text);
}});
}
}
I think I should be able to replace the static long INTERVAL with a call to
java.util.random
in a way that would work for me. However, I can't even get this example to
finish/abort/end properly.
After running this example, I have to go to "Manage Apps" and click "Force
Close" to kill it.
I'm not really sure if this is example is the best way to handle it either
but it is where I seem to be
zeroing in on. Any suggestions?
Thank you sooo much for your help,
Ron
On Tue, Dec 21, 2010 at 11:53 PM, TreKing <[email protected]> wrote:
> On Sun, Dec 19, 2010 at 12:20 PM, Ronoli <[email protected]> wrote:
>
>> Hello, can anyone show me the proper way to resolve my problem?
>
>
> I do think I understand what your actual problem is. What, specifically,
> are you having trouble with given your pseudo-code description?
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en