我在这个问题上已经阅读了大约100个问题和答案,但我似乎无法让这个工作.我正试图Service从一个开始Activity.我的清单文件似乎没问题,我启动的方式Service似乎也是正确的.LogCat中显示以下错误:
ActivityManager(1296): Unable to start service Intent
{ cmp=com.exercise.AndroidClient/com.client.Communication }: not found
Run Code Online (Sandbox Code Playgroud)
我试图通过在我的调用中启动该服务Activity:
startService(new Intent(getApplicationContext(), Communication.class));
Run Code Online (Sandbox Code Playgroud)
该Service如下:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
我的清单文件中的条目是:
<?xml version="1.0" encoding="utf-8" ?>
<manifest …Run Code Online (Sandbox Code Playgroud)