views:

33

answers:

2

Hi! I have an Android service which sends broadcast intents. I'm trying to get those intents in another application, which is an Android service. I wrote this in my manifest:

<!-- Service -->
<service android:enabled="true" android:name="...MyService"></service>

<!-- Receiver -->
<receiver android:name="...MyReceiver">
   <intent-filter>
      <action android:name="..."></action>
      <action android:name="..."></action>
   </intent-filter>
</receiver>

and this in my MyReceiver class:

public class ScannerBroadcastReceiver extends BroadcastReceiver {
   @Override
   public void onReceive(Context context, Intent intent) {
      String action = intent.getAction();
      // Process action.
      Log.d(Globals.LOG_TAG, "Intent received.");
      ...

Unfortunately I never get the onReceive method invoked. Any idea why? I start this service from another test application, so this is set as an Android library. The service is correctly started but this receiver is receiving nothing. Any idea what I'm doing wrong? Thanks!

A: 

In manifest must be: android:name=".[package].ScannerBroadcastReceiver"

Sorry, my bad. Seems I forgot to rename the class to MyService. In the code this is correct.
Luca
A: 

I solved the problem and I suppose it is due to the fact that this project was set as a library. If I don't set it this way the intent is correctly received. I haven't read about this anywhere.

Luca