Android:无法启动服务意图:未找到? [英] Android: unable to start service intent: not found?

查看:38
本文介绍了Android:无法启动服务意图:未找到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,我不是第一个遇到这个问题的人,但我尝试了很多解决方案,我找到了,但没有一个可行...也许你能找到错误

I know, I am not the first onbe with this problem, but I tried so many solutions, I have found and no one works... maybe you could find the error

错误(根据其他设置,在没有 .class 和/.Client 的情况下也是如此)

The error (also came so without .class and with /.Client depending on other settings)

12-02 16:40:15.359:W/ActivityManager(74):无法启动服务意图 { act=com.android.fh.EnOceanApp.Client.class }:未找到

12-02 16:40:15.359: W/ActivityManager(74): Unable to start service Intent { act=com.android.fh.EnOceanApp.Client.class }: not found

在清单中,这包含在应用程序中,在活动之外(也在活动中尝试并使用.Client"

In the manifest, this is included in application, out of activities (tried it also in activities and with ".Client"

onCreate() 中的代码

The code in onCreate()

    startService(new Intent(this, Client.class)); 

 startService(new Intent(this.getApplicationContext(), Client.class));

Intent intent=new Intent("com.android.fh.EnOceanApp.Client.class");
    this.startService(intent);

  Intent intent=new Intent("com.android.fh.EnOceanApp.Client");
    this.startService(intent);

现在,我不再有想法了....com.android.fh.EnOceanApp 是包,Client.java 是这个包中的服务类

And now, I dont have an Idea anymore.... com.android.fh.EnOceanApp is the package, Client.java the service-class in this package

还有我忘记的清单:

  <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".EnOceanAppActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>      
        </activity>

      <activity android:name=".ListView" 
          android:label="List View">
      </activity> 
      <activity android:name=".GraphView" 
          android:label="Graph View">
      </activity>
      <service 
            android:name=".Client"></service> //with and without ., of course without this comment
    </application>

推荐答案

所以.. 只是为了最终帮助他人或不帮助他人:

So.. just to eventually help others or not:

我创建了一个新项目,复制了源代码并尝试运行它:现在找到了该服务.有什么区别,或者换句话说:我认为可能会产生什么问题:长包名或以 com.android.. 开头.在新项目中我只是选择了 com.enocean

I made a new project, copied the sources and tried to run it: the service was found now. What was the difference, or in other words: what do I think, might give problems: the long package name or the beginning with com.android... In the new project I just chose com.enocean

这篇关于Android:无法启动服务意图:未找到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆