Say MyServiceand MyClient, both are running, although it MyClientis currently in the background. If MyServicesends the intention in MyClientthrough:
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 to get this intention in MyClient? Running this code calls onResume () in MyClient, but since it is already running, the call getIntent()returns the Intent originally created by MyClient, which alwaysandroid.intent.action.MAIN
source
share