ServiceConnection :: onServiceConnected is not called, although Context :: bindService returns true?

I am trying to bind a service that was started when loading from activity. The code to run at boot was mainly taken from the instant messenger .

This is the definition of AndroidManifest.xml for 3 main components:

<!-- Receiver --> <receiver android:name=".receiver.LifestylePPAutoStarter" android:process="android.process.lifestylepp"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> <!-- Service --> <service android:name=".service.LifestylePPService" android:process="android.process.lifestylepp" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="edu.gatech.lifestylepp.ILifestylePPService" /> <action android:name="edu.gatech.lifestylepp.SERVICE" /> </intent-filter> </service> <!-- Activity --> <activity android:name=".app.LifestylePPActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 

The receiver starts the service at boot without any problems. However, when I try to associate a service with my activity, Context :: bindService returns true, but ServiceConnection :: onServiceConnected is never called. Also, when I start a service from an action, it works as expected (ServiceConnection :: onServiceConnected is called).

+4
source share
1 answer

Also, when I start the service from the activity it works as expected (ServiceConnection :: onServiceConnected is called).

startService() does not include a ServiceConnection object.

Get rid of the android:process="android.process.lifestylepp" lines from your manifest. This can be the source of your difficulties, and, more importantly, it is very unlikely that you really need the two processes and all the overhead that is required.

+2
source

All Articles