I am following a tutorial to setup a service to start on boot where the last piece of the code is:
Make an entry of this service in AndroidManifest.xml as
<service android:name="MyService">
<intent-filter>
<action
android:name="com.wissen.startatboot.MyService" />
</intent-filter>
</service>
Now start this service in the BroadcastReceiver MyStartupIntentReceiver’s onReceive method as
public void onReceive(Context context, Intent intent) {
Intent serviceIntent = new Intent();
serviceIntent.setAction("com.wissen.startatboot.MyService");
context.startService(serviceIntent);
}
As you see it uses intent-filters and when starts the service adds action. Can I just use
startService(new Intent(this, MyService.class));
What's the advantage of one compared to the other?