tags:

views:

151

answers:

2

Say MyService and MyClient are both running, although MyClient is currently in the background. If MyService sends an Intent to MyClient via:

Intent i = new Intent(MYService.this, MyClient.class);
i.setAction("com.test.MyService.ACTION_SERVICE");
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

How do I get this Intent in MyClient? Running this code triggers onResume() in MyClient, but because it's already running, calling getIntent() returns the Intent that initially created MyClient, which is always android.intent.action.MAIN

+1  A: 

override onNewIntent() and make sure you flag the intent so that it doesn't start a new instance of your activity

Falmarri
A: 

This does not work. The onNewIntent never get called. My settings were all default, and no new instance was created. Any other settings needed to make the onNewIntent be called?