Normaly, I use a simple code to put a Toast
when the user change the AIRPLANE_MODE
, and it work using targetSdkVersion 25
.
My AirPlaneModeReceiver :
public class AirPlaneModeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "I receive a Broadcast", Toast.LENGTH_SHORT).show();
}
}
The part of the Manifest where I declare my Receiver :
<receiver android:name=".AirPlaneModeReceiver">
<intent-filter>
<action android:name="android.intent.action.AIRPLANE_MODE"/>
</intent-filter>
</receiver>
But when I change the target SDK version to targetSdkVersion 26
, it's not working at all...
Why ?
As per documentation:
you should remove any broadcast receivers that are registered for implicit broadcast intents.
https://developer.android.com/about/versions/oreo/android-8.0-migration.html
see Section "Remove broadcast receivers from your manifest file"