Hello, I hope this is the right place for this type of question. If not, sorry in advance and if you know of the right place, I'd be interested. Thanks!
I have a very simple app (my first Android app) that's not working as I expect and does not work as examples have shown. I have a brand new installation environment using Eclipse. My target device and Android 2.1 (API Level 7).
Very simple, I have an activity and a service. I'd like to start the service from the activity and have the service execute some code every couple of seconds. I have no problem getting the service to start, but the timer never seems to fire. For the service I have (relevant code)
private Timer timer = new Timer();
@Override
public void onStart(Intent intent, int startid) {
Toast.makeText(MyService.this,"Starting", Toast.LENGTH_LONG).show();
}
public void onCreate() {
super.onCreate();
Toast.makeText(MyService.this,"One", Toast.LENGTH_LONG).show();
timer.scheduleAtFixedRate( new TimerTask() {
public void run() {
Toast.makeText(MyService.this,"Act", Toast.LENGTH_LONG).show();
}
}, 0, 3000);
}
Here the Toast shows "Starting" then "One", then nothing else... Any thoughts?
I have a very simple app (my first Android app) that's not working as I expect and does not work as examples have shown. I have a brand new installation environment using Eclipse. My target device and Android 2.1 (API Level 7).
Very simple, I have an activity and a service. I'd like to start the service from the activity and have the service execute some code every couple of seconds. I have no problem getting the service to start, but the timer never seems to fire. For the service I have (relevant code)
private Timer timer = new Timer();
@Override
public void onStart(Intent intent, int startid) {
Toast.makeText(MyService.this,"Starting", Toast.LENGTH_LONG).show();
}
public void onCreate() {
super.onCreate();
Toast.makeText(MyService.this,"One", Toast.LENGTH_LONG).show();
timer.scheduleAtFixedRate( new TimerTask() {
public void run() {
Toast.makeText(MyService.this,"Act", Toast.LENGTH_LONG).show();
}
}, 0, 3000);
}
Here the Toast shows "Starting" then "One", then nothing else... Any thoughts?