2

Hi: I want to start a service which is situated in a connected library project. All concerning classes are in the library.

The service is called from an activity located in the library:

Intent serviceIntent = new Intent();
serviceIntent.setAction("org.example.library.MY_ACTION");
startService(serviceIntent);

In the manifest files -both at library and application- it is noted:

    <service android:name="org.example.library.SomeLibraryClass">
        <intent-filter>
            <action android:name="org.example.library.MY_ACTION" />
        </intent-filter>
    </service>

Unable to start service Intent { act=org.example.android.SomeLibraryClass (has extras) }: not found

It seems like Android is looking for a class in the application but not in the library. Anyone had this behavior before?

Sney
  • 2,486
  • 4
  • 32
  • 48

1 Answers1

2

You need to specify the package of the application when calling an Intent defined in a library:

Intent serviceIntent = new Intent();
serviceIntent.setAction("org.example.library.MY_ACTION");
serviceIntent.setPackage("org.example.application");
startService(serviceIntent);
MasterScrat
  • 7,090
  • 14
  • 48
  • 80