gpt4 book ai didi

android - 带有 AIRPLANE_MODE 的广播接收器不适用于 SDK 26

转载 作者:太空宇宙 更新时间:2023-11-03 13:11:02 25 4
gpt4 key购买 nike

通常,当用户更改 AIRPLANE_MODE 时,我使用一个简单的代码来放置一个 Toast,并且它使用 targetSdkVersion 25 工作。

我的 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();

}
}

Manifest 中声明接收者的部分:

<receiver android:name=".AirPlaneModeReceiver">
<intent-filter>
<action android:name="android.intent.action.AIRPLANE_MODE"/>
</intent-filter>
</receiver>

但是当我将目标 SDK 版本更改为 targetSdkVersion 26 时,它根本不起作用...为什么?

最佳答案

根据文档:

您应该删除所有为隐式广播 Intent 注册的广播接收器。

https://developer.android.com/about/versions/oreo/android-8.0-migration.html

请参阅“从您的 list 文件中删除广播接收器”部分

关于android - 带有 AIRPLANE_MODE 的广播接收器不适用于 SDK 26,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44919613/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com