I’ve read probably 100 questions and answers on this issue, but I cant seem to get this working. I’m trying to start a Service from an Activity. My manifest file seems OK, the way I’m starting the Service also seems to be correct. The following error is showing up in LogCat:
ActivityManager(1296): Unable to start service Intent
{ cmp=com.exercise.AndroidClient/com.client.Communication }: not found
I’m attempting to start the service by calling this in my Activity:
startService(new Intent(getApplicationContext(), Communication.class));
The Service is the following:
public class Communication extends Service {
public Communication() {
super();
}
@Override
public void onCreate() {
super.onCreate();
Log.i("Service", "Created service");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("Service", "onStartCommand called");
return START_STICKY;
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
}
The entry in my manifest file is:
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exercise.AndroidClient" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/sms" android:label="@string/app_name" >
<activity> ... </activity>
<service android:enabled="true" android:name=".Communication" />
</application>
</manifest>
Any advice is greatly appriciated.
Where is the Communication class?
In your manifest you declare a service with
android:name=".Communication", this means that your service class should be located incom.exercise.AndroidClient.CommunicationCheck that the packages are correct. Note that the “.” (dot) refers to the root of your package (ie the package declared in the manifest). So, for example, if your package is
com.exercise.AndroidClientand your service class is undercom.exercise.AndroidClient.services.Communicationyou need to declare the service like this:Or specify the full package: