I am having trouble starting a Service. It crashes before the application even starts.
Intent repSer = new Intent(this,repService.class);
startService(repSer);
this is the Service itself.:
public class repService extends Service {
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
while(true){
Thread timer = new Thread(){
public void run(){
try {
sleep(5000);
// do something
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// do something
}
}
};
timer.start();
}
}
}
perhaps this is wrong?
my manifest entry:
<service android:name = ".repService"/>
</application>
You’re just constantly looping through the while and starting new Threads with timers inside. You’re probably overloading with Threads. As fast as the while() statement can loop you’re creating another Thread and starting it.