Reputation: 2506
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?
Upvotes: 2
Views: 2091
Reputation: 7366
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);
Upvotes: 2