我无法启动Service
. 它甚至在应用程序启动之前就崩溃了。
Intent repSer = new Intent(this,repService.class);
startService(repSer);
这就是它Service
本身。:
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();
}
}
}
也许这是错的?我的清单条目:
<service android:name = ".repService"/>
</application>