I'm developing an application that needs to detect when the headphones are plugged in and no matter what are you doing in that moment, a PopUp appears with some information and two options like "open my app", "not now".
The problem is that the PopUp works if I'm in the application but doesn't work in any other screen...
This is my code actually when I detect the headphones:
Intent myIntent = new Intent(getApplicationContext(), PopUpActivity.class);
startActivity(myIntent);
and this is in the manifest.xml
<activity
android:name=".PopUpActivity"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:taskAffinity="">
</activity>
My problem is that the Pop Up does not appear, but the detection of the headphones is working.