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 android:name=".receiver.LifestylePPAutoStarter" android:process="android.process.lifestylepp"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> <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 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).
source share