Skip to content Skip to sidebar Skip to footer

Starting Service From Other Apk - Throws Noclassdeffounderror Exception

i have two projects in Eclipse: service and UI client. In onCreate in UI client I have: startService(new Intent(this, ExampleService.class)); but this fragment: ExampleService.cla

Solution 1:

If you're trying to use a service from a different package, you can't use the simple invocation in the Android example because your first argument references the context of your current package, which is by definition the wrong place to look.

You have to create the intent and then use setClassName(String, String), where the arguments are the other package and the full name of the service. For example:

Intentintent=newIntent();
intent.setClassName("com.example.Something", "com.example.Something.MyService");
startService(intent);

Also note this is a simple case which presumes a default action with no arguments - you also have to make sure that the package containing the service has android:exported="true" set for the service if you don't have any intent-filter declarations, otherwise the call will fail due to a lack of permissions.

Solution 2:

Use a broadcast/broadcast receiver

Solution 3:

The service needs to be declared in the AndroidManifest.xml of your client.

Post a Comment for "Starting Service From Other Apk - Throws Noclassdeffounderror Exception"