android– 无法启动服务Intent

android– 无法启动服务Intent,第1张

概述我在这个问题上已经阅读了大约100个问题和答案,但我似乎无法让这个工作.我正在尝试从活动中启动服务.我的清单文件似乎没问题,我启动服务的方式似乎也是正确的. LogCat中显示以下错误:ActivityManager(1296): Unable to start service Intent { cmp=com.exercise.AndroidClient/

我在这个问题上已经阅读了大约100个问题和答案,但我似乎无法让这个工作.我正在尝试从活动中启动服务.我的清单文件似乎没问题,我启动服务的方式似乎也是正确的. LogCat中显示以下错误:

ActivityManager(1296): Unable to start service Intent{ cmp=com.exercise.AndroIDClIEnt/com.clIEnt.Communication }: not found

我试图通过在我的Activity中调用它来启动服务:

startService(new Intent(getApplicationContext(),Communication.class));

该服务如下:

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;    }}

我的清单文件中的条目是:

任何建议都非常适合.最佳答案沟通课在哪里?

在您的清单中,您使用androID:name =“.Communication”声明一个服务,这意味着您的服务类应位于com.exercise.AndroIDClIEnt.Communication中

检查包装是否正确.注意“.” (点)指的是包的根(即清单中声明的​​包).因此,例如,如果您的包是com.exercise.AndroIDClIEnt,并且您的服务类在com.exercise.AndroIDClIEnt.services.Communication下,则需要声明服务,如下所示:

或者指定完整的包:

总结

以上是内存溢出为你收集整理的android – 无法启动服务Intent全部内容,希望文章能够帮你解决android – 无法启动服务Intent所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1139788.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)