我对Android非常陌生,我试图了解这项服务。为什么服务不是从我的情况开始的?
我的清单文件如下:
<!--The invoice launcher service-->
<service android:process=":invoice_background"
android:name="InvoiceManagerService"
android:label="invoice_service" />
<!--The receiver-->
<receiver android:name="InvoiceStartupReceiver"
android:process=":invoice_background">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
我的服务是这样的:
public class InvoiceManagerService extends Service {
public IBinder onBind(Intent intent) {
return null;
}
}
和我的接收机是这样的:没有任何错误得到执行
public class InvoiceStartupReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Intent invoiceService = new Intent(context, InvoiceManagerService.class);
context.startService(invoiceService);
}
}
我的应用程序。但没有创建服务!我犯了什么错误?
在此先感谢。
1 /您是否有权接收boot_completed广播? 2 /你重新启动你的手机吗? 3 /你可以在logcat中看到什么? – njzk2 2013-03-07 09:51:56
@ njzk2:我正在测试我的模拟器。而在logcat中,我没有看到任何说我的服务已经启动的日志。 – batman 2013-03-07 09:55:01