Reputation: 4908
I'm very new to Android and I'm trying to understand the service.
My manifest file looks:
<!--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>
My service looks like :
public class InvoiceManagerService extends Service {
public IBinder onBind(Intent intent) {
return null;
}
}
and my receiver looks like:
public class InvoiceStartupReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Intent invoiceService = new Intent(context, InvoiceManagerService.class);
context.startService(invoiceService);
}
}
My app is getting executed without any error. But no services been created! Where I'm making the mistake?
Thanks in advance.
Upvotes: 2
Views: 54
Reputation: 1784
I'm very new to Android
Because of this sentence I suggest you use an IntentService
instead of Service
as IntentService is much easier to use. I wrote some basic code for another answer where the person wanted to download a file and then inform the Activity this had happened. It will show you proper use of the IntentService and how to call the task is finished.
Upvotes: 0
Reputation: 2928
Use this permission in manifest
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Upvotes: 3