Android: unable to start service intent: not found?

后端 未结 8 1375
清酒与你
清酒与你 2020-12-17 14:19

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

The error (also cam

相关标签:
8条回答
  • 2020-12-17 15:11

    So.. just to eventually help others or not:

    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

    0 讨论(0)
  • 2020-12-17 15:12

    Thanks to user njzk2 for letting me notice what was happening.

    I've had the same problem. It seem that Android OS can't find the service class that you've requested if you haven't registered before in the manifest file of your proyect.

    Remember that a service is like an activity but without graphic interface. It means that the services needs to be registered before you can use them

    This is how you register the service in your Android project:

    <application>
        <!-- your code -->
        <activity>
            <!-- your code  -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name="com.your.own.service.class"></service>
    </application>
    

    Just Remember that YourService class needs to extend from Service, if not your class won't be a service.

    public class YourService extends Service{}
    
    0 讨论(0)
提交回复
热议问题