简体   繁体   English

API级别低于26的通知代码

[英]Notification code for API levels lower than 26

I am trying to target my Android application from API level 23 to the latest API level. 我正在尝试将我的Android应用程序从API级别23定位到最新的API级别。 However starting in Android 8.0 (API level 26), all notifications must be assigned to a channel which wasn't the case previously. 但是,从Android 8.0(API级别26)开始,必须将所有通知分配给以前不是这种情况的通道。 Right now I am checking the condition if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) to make the notification with the NotificationChannel if API level is greater than 26, so my question is that will the import statement for the NotificationChannel import android.app.NotificationChannel; 现在我正在检查条件if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)如果API级别大于26,则使用NotificationChannel进行通知,所以我的问题是NotificationChannel import android.app.NotificationChannel;的import语句import android.app.NotificationChannel; cause an issue in the API versions lower than 26. Should I maintain different activities for the different APIs? 导致API版本低于26的问题。我应该为不同的API维护不同的活动吗?

will the import statement for the NotificationChannel import android.app.NotificationChannel; 将NotificationChannel的import语句导入android.app.NotificationChannel; cause an issue in the API versions lower than 26. 导致API版本低于26的问题。

No. 没有。

Trying to use NotificationChannel on older devices would be a problem, but that is what the if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) is for. 尝试在旧设备上使用 NotificationChannel会出现问题,但这就是if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)的用途。 Simply having the import will not be an issue. 简单地进行导入不会成为问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM