我可以让BroadcastReciver工作,但我不知道为什么intnet启动服务的代码有错误。BroadcastReciver在设备开启时启动服务?
public class BroadCastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Intent backGround = new Intent(this,BackGround.class);
startService(backGround);
}
}
错误的是与新的意图(这一点,BackGround.class)和startService();现在我想我需要为startService方法实现服务类,并且(this)需要其他东西,但是我仍然对此感到陌生,并且不确定这里要做什么。任何帮助和解释将非常好谢谢。
有什么错误?请发布您的logcat –
我认为你应该使用'context'而不是'this' – ramaral