I have a service class. I have exported this class to jar and I have embed the jar in my client app.
When needed, I call the service class. When I try to do this, I get the following error:
Unable to start service Intent {comp={com.sample.service/com.sample.service.serviceClass}} : not found
I have other class apart from the service class, which I am able to access (create object of that class) which are inside the same jar.
I feel I have missed out some thing in my configuration or manifest or so.
Please help me identifying the same. My code is below:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent () ; intent.setClassName("com.sample.service" ,"com.sample.service.serviceClass") ; this.startService(intent) ; // when I call this line I get the message... // binding other process continue here }
Client manifest.xml
<service android:name="com.sample.service.serviceClass" android:exported="true" android:label="@string/app_name" android:process=":remote"> <intent-filter><action android:name="com.sample.service.serviceClass"></action> </intent-filter> </service>
Thanks in advance,
Vinay
You can start a service from an activity or other application component by passing an Intent to startService() or startForegroundService() . The Android system calls the service's onStartCommand() method and passes it the Intent , which specifies which service to start.
IntentService runs outside the application in a background process, so the process would run even if your application is closed. Google now recommends using the JobIntentService, which is included as part of the support library. On pre-Android O devices, a normal IntentService will be dispatched in the background.
The Intent is not deprecated the problem is with your itemClickable. class because it is not recognized.
For anyone else coming across this thread I had this issue and was pulling my hair out. I had the service declaration OUTSIDE of the '< application>' end tag DUH!
RIGHT:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ...> ... <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity ...> ... </activity> <service android:name=".Service"/> <receiver android:name=".Receiver"> <intent-filter> ... </intent-filter> </receiver> </application> <uses-permission android:name="..." />
WRONG but still compiles without errors:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ...> ... <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity ...> ... </activity> </application> <service android:name=".Service"/> <receiver android:name=".Receiver"> <intent-filter> ... </intent-filter> </receiver> <uses-permission android:name="..." />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With