I have two applications in two different projects in eclipse. In one appendix (A), action (A1) is defined that starts first. Then I start with this activity the second activity (B1) in the second project (B). It works great.
I start it as follows:
Intent intent = new Intent("pacman.intent.action.Launch"); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent);
Now I want to send intentions before two actions using broadcast receivers. In action A1, I send intentions as follows:
Intent intent = new Intent("pacman.intent.action.BROADCAST"); intent.putExtra("message","Wake up."); sendBroadcast(intent);
The part of the manifest file in action A1 that is responsible for this translation is as follows:
<activity android:name="ch.ifi.csg.games4blue.games.pacman.controller.PacmanGame" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.BROADCAST" /> </intent-filter> </activity>
In the receiving activity, I define the recipient as follows in the manifest file:
<application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".PacmanGame" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="pacman.intent.action.Launch" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <receiver android:name="ch.ifi.csg.games4blue.games.pacman.controller.MsgListener" /> </activity> </application>
The class message listener is implemented as follows:
public class MsgListener extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { System.out.println("Message at Pacman received!"); } }
Unfortunately, the message is never received. Although the method in action A1 is called, I never get the intention in B1.
Any clues how to solve this? Many thanks!
android broadcastreceiver
anon
source share