private void showNotification2(Context context, int iid, String title, String text) {    String id = "my_channel_01";    String name = "我是渠道名字";    NotificationManager notificationManager = (NotificationManager) MyApplication.mContext.getSystemService(NOTIFICATION_SERVICE);    Notification notification = null;    Toast.makeText(this, "qweqweqwewqewq", Toast.LENGTH_SHORT).show();    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {        NotificationChannel mChannel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW);        Log.i("log", mChannel.toString());        notificationManager.createNotificationChannel(mChannel);        notification = new Notification.Builder(this)                .setChannelId(id)                .setContentTitle("5 new messages")                .setContentText("hahaha")                .setSmallIcon(R.mipmap.ic_launcher).build();    } else {        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(MyApplication.mContext)                .setContentTitle("5 new messages")                .setContentText("hahaha")                .setSmallIcon(R.mipmap.ic_launcher)                .setOngoing(true)                .setChannel(id);//无效        notification = notificationBuilder.build();    }    notificationManager.notify(iid, notification);}

更多相关文章

  1. Android(安卓)TextView中android:textIsSelectable属性在Recycle
  2. Android通过图片名字获得ID
  3. Android(安卓)Service一前台服务(四)
  4. Android(安卓)Ant打包及其环境变量配置
  5. Android笔记之一:Hello, Android
  6. Android(安卓)多版本多渠道打包
  7. App应用之提交到各大市场渠道
  8. Android(安卓)setTheme设置透明主题无效
  9. Android(安卓)CheckBox中设置padding无效解决办法

随机推荐

  1. phonegap3.0 本地android 环境命令配置
  2. Android系统级开发,apktool无法反编译
  3. Android的生命周期图
  4. Android 绘图机制
  5. Service Manager进程,发送BC_REPLY,唤醒Fre
  6. 15款android设备上的代码编辑器
  7. python搭建服务器实现两个Android客户端
  8. Android 依赖注入(DI)框架 Dagger
  9. Android Treble结构:Part 2 - 概述
  10. android源码分析 - AysncTask