Reputation: 9574
I have a weird issue with my Service not starting. I have my manifest file with the service, and have called it. But still it does not open up.
<service
android:name=".com.taxeeta.ForHire"
android:enabled="true" />
Calling the intent
Intent serviceIntent = new Intent();
serviceIntent.setAction("com.taxeeta.ForHire");
startService(serviceIntent);
Service
public class ForHire extends Service
I wonder what I am missing here.
Upvotes: 0
Views: 203
Reputation: 1550
Just call startService(new Intent(getApplicationContext(),ForHire.class));
Every thing is fine in your menifest.
No need to set Action according to your menifest.
Upvotes: 2
Reputation: 12477
Change
android:name=".com.taxeeta.ForHire"
with
android:name="com.taxeeta.ForHire"
or if the service is on the root package
android:name=".ForHire"
Also, you should use Intent.setClass( ) instead of setAction, since you don't have an IntentFilter declared for your service and you most likely, trying to use an explicit intent.
Upvotes: 3
Reputation: 3192
When you Declare service in Manifest file use like this.
<service android:name=".ForHire">
<intent-filter>
<action android:name="com.taxeeta.ForHire" />
</intent-filter>
</service>
& call service Like this way.
Intent serviceIntent = new Intent();
serviceIntent.setAction("com.taxeeta.ForHire");
startService(serviceIntent);
For More information about Service refer this Documentation http://developer.android.com/guide/components/services.html
Upvotes: 2
Reputation: 16064
You have a problem in the declaration of the service in your manifest. Change it to:
<service android:name="com.taxeeta.ForHire" />
(notice the .
[dot] removed). Also make sure service
is a child element of your application
element, which is a must for the service to be recognized by the Android OS.
Upvotes: 1