Android-Notification(通知)

Android安卓状态栏消息推送通知(Notification) 我从不猜测,猜测是一个很坏的习惯——会影响正常的逻辑推理能力。              ——阿瑟·柯南·道尔 《福尔摩斯探案集》 近日,在做安卓项目开发的时候涉及到状态栏通知的需求,查了资料,总结一个简单有效的方法,下面放上代码(Kotlin版): //该代码为Kotlin,读者可根据需求稍作调整 val notificationManager = getSystemServi... 阅读详情

Notification(通知)

Notification 概述
是一种具有全局效果的通知,可以在系统的通知栏中显示,首先会表示为一个图标的形式,当用户向下滑动的时候,展示出通知具体的内容

Notification 的基本操作
Notification 的基本操作主要有创建、更新、取消这三种。一个 Notification 的必要属性有三项,如果不设置则在运行时会抛出异常:

小图标,通过 setSmallIcon() 方法设置
标题,通过 setContentTitle() 方法设置
内容,通过 setContentText() 方法设置

创建 Notification
Notification : 通知对应类,保存通知相关的数据。
NotificationManager : NotificationManager 是通知管理类,它是一个系统服务。调用 NotificationManager 的 notify() 方法可以向系统发送通知。

获取 NotificationManager 对象:
NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

代码:
private void sendNotification() {
//获取NotificationManager实例
NotificationManager notifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//实例化NotificationCompat.Builde并设置相关属性
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
//设置小图标
.setSmallIcon(R.mipmap.icon_fab_repair)
//设置通知标题
.setContentTitle(“最简单的Notification”)
//设置通知内容
.setContentText(“只有小图标、标题、内容”)
//设置通知时间,默认为系统发出通知的时间,通常不用设置
//.setWhen(System.currentTimeMillis());
//通过builder.build()方法生成Notification对象,并发送通知,id=1
notifyManager.notify(1, builder.build());
}

给 Notification 设置 Action
otification 跳转到 MainActivity 的效果,代码如下:
/**

  • 发送一个点击跳转到MainActivity的消息
    */
    private void sendSimplestNotificationWithAction() {
    //获取PendingIntent
    Intent mainIntent = new Intent(this, MainActivity.class);
    PendingIntent mainPendingIntent = PendingIntent.getActivity(this, 0, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    //创建 Notification.Builder 对象
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    //点击通知后自动清除
    .setAutoCancel(true)
    .setContentTitle(“我是带Action的Notification”)
    .setContentText(“点我会打开MainActivity”)
    .setContentIntent(mainPendingIntent);
    //发送通知
    mNotifyManager.notify(3, builder.build());
    }

发送具有 Action 的通知多了创建 Intent 、 PendingIntent 和 setContentIntent()

PendingIntent 是一种特殊的 Intent ,字面意思可以解释为延迟的 Intent ,用于在某个事件结束后执行特定的 Action

PendingIntent 主要可以通过以下三种方式获取:
//获取一个用于启动 Activity 的 PendingIntent 对象
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags);

//获取一个用于启动 Service 的 PendingIntent 对象
public static PendingIntent getService(Context context, int requestCode, Intent intent, int flags);

//获取一个用于向 BroadcastReceiver 广播的 PendingIntent 对象
public static PendingIntent getBroadcast(Context context, int requestCode, Intent intent, int flags)

PendingIntent 具有以下几种 flag:
FLAG_CANCEL_CURRENT:如果当前系统中已经存在一个相同的 PendingIntent 对象,那么就将先将已有的 PendingIntent 取消,然后重新生成一个 PendingIntent 对象。

FLAG_NO_CREATE:如果当前系统中不存在相同的 PendingIntent 对象,系统将不会创建该 PendingIntent 对象而是直接返回 null 。

FLAG_ONE_SHOT:该 PendingIntent 只作用一次。

FLAG_UPDATE_CURRENT:如果系统中已存在该 PendingIntent 对象,那么系统将保留该 PendingIntent 对象,但是会使用新的 Intent 来更新之前 PendingIntent 中的 Intent 对象数据,例如更新 Intent 中的 Extras

取消 Notification
取消通知有如下 5 种方式:
点击通知栏的清除按钮,会清除所有可清除的通知
设置了 setAutoCancel() 或 FLAG_AUTO_CANCEL 的通知,点击该通知时会清除它
通过 NotificationManager 调用 cancel(int id) 方法清除指定 ID 的通知
通过 NotificationManager 调用 cancel(String tag, int id) 方法清除指定 TAG 和 ID 的通知
通过 NotificationManager 调用 cancelAll() 方法清除所有该应用之前发送的通知

Notification 的基本操作代码
/**

  • 为了方便,大部分通知都没设置对应的Action,即PendingIntent

  • 除了sendFlagAutoCancelNotification()方法
    */
    public class SimpleNotificationActivity extends Activity implements View.OnClickListener {

    //Notification.FLAG_FOREGROUND_SERVICE //表示正在运行的服务
    public static final String NOTIFICATION_TAG = “littlejie”;
    public static final int DEFAULT_NOTIFICATION_ID = 1;

    private NotificationManager mNotificationManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simple_notification);

     findViewById(R.id.btn_remove_all_notification).setOnClickListener(this);
     findViewById(R.id.btn_send_notification).setOnClickListener(this);
     findViewById(R.id.btn_remove_notification).setOnClickListener(this);
     findViewById(R.id.btn_send_notification_with_tag).setOnClickListener(this);
     findViewById(R.id.btn_remove_notification_with_tag).setOnClickListener(this);
     findViewById(R.id.btn_send_ten_notification).setOnClickListener(this);
     findViewById(R.id.btn_send_flag_no_clear_notification).setOnClickListener(this);
     findViewById(R.id.btn_send_flag_ongoing_event_notification).setOnClickListener(this);
     findViewById(R.id.btn_send_flag_auto_cancecl_notification).setOnClickListener(this);
    
     mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
    

    }

    @Override
    public void onClick(View v) {
    switch (v.getId()) {
    case R.id.btn_remove_all_notification:
    //移除当前 Context 下所有 Notification,包括 FLAG_NO_CLEAR 和 FLAG_ONGOING_EVENT
    mNotificationManager.cancelAll();
    break;
    case R.id.btn_send_notification:
    //发送一个 Notification,此处 ID = 1
    sendNotification();
    break;
    case R.id.btn_remove_notification:
    //移除 ID = 1 的 Notification,注意:该方法只针对当前 Context。
    mNotificationManager.cancel(DEFAULT_NOTIFICATION_ID);
    break;
    case R.id.btn_send_notification_with_tag:
    //发送一个 ID = 1 并且 TAG = littlejie 的 Notification
    //注意:此处发送的通知与 sendNotification() 发送的通知并不冲突
    //因为此处的 Notification 带有 TAG
    sendNotificationWithTag();
    break;
    case R.id.btn_remove_notification_with_tag:
    //移除一个 ID = 1 并且 TAG = littlejie 的 Notification
    //注意:此处移除的通知与 NotificationManager.cancel(int id) 移除通知并不冲突
    //因为此处的 Notification 带有 TAG
    mNotificationManager.cancel(NOTIFICATION_TAG, DEFAULT_NOTIFICATION_ID);
    break;
    case R.id.btn_send_ten_notification:
    //连续发十条 Notification
    sendTenNotifications();
    break;
    case R.id.btn_send_flag_no_clear_notification:
    //发送 ID = 1, flag = FLAG_NO_CLEAR 的 Notification
    //下面两个 Notification 的 ID 都为 1,会发现 ID 相等的 Notification 会被最新的替换掉
    sendFlagNoClearNotification();
    break;
    case R.id.btn_send_flag_auto_cancecl_notification:
    sendFlagOngoingEventNotification();
    break;
    case R.id.btn_send_flag_ongoing_event_notification:
    sendFlagAutoCancelNotification();
    break;
    }
    }

    /**

    • 发送最简单的通知,该通知的ID = 1
      */
      private void sendNotification() {
      //这里使用 NotificationCompat 而不是 Notification ,因为 Notification 需要 API 16 才能使用
      //NotificationCompat 存在于 V4 Support Library
      NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
      .setSmallIcon(R.mipmap.ic_launcher)
      .setContentTitle(“Send Notification”)
      .setContentText(“Hi,My id is 1”);
      mNotificationManager.notify(DEFAULT_NOTIFICATION_ID, builder.build());
      }

    /**

    • 使用notify(String tag, int id, Notification notification)方法发送通知
    • 移除对应通知需使用 cancel(String tag, int id)
      */
      private void sendNotificationWithTag() {
      NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
      .setSmallIcon(R.mipmap.ic_launcher)
      .setContentTitle(“Send Notification With Tag”)
      .setContentText("Hi,My id is 1,tag is " + NOTIFICATION_TAG);
      mNotificationManager.notify(NOTIFICATION_TAG, DEFAULT_NOTIFICATION_ID, builder.build());
      }

    /**

    • 循环发送十个通知
      */
      private void sendTenNotifications() {
      for (int i = 0; i < 10; i++) {
      NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
      .setSmallIcon(R.mipmap.ic_launcher)
      .setContentTitle(“Send Notification Batch”)
      .setContentText("Hi,My id is " + i);
      mNotificationManager.notify(i, builder.build());
      }
      }

    /**

    • 设置FLAG_NO_CLEAR
    • 该 flag 表示该通知不能被状态栏的清除按钮给清除掉,也不能被手动清除,但能通过 cancel() 方法清除
    • Notification.flags属性可以通过 |= 运算叠加效果
      */
      private void sendFlagNoClearNotification() {
      NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
      .setSmallIcon(R.mipmap.ic_launcher)
      .setContentTitle(“Send Notification Use FLAG_NO_CLEAR”)
      .setContentText(“Hi,My id is 1,i can’t be clear.”);
      Notification notification = builder.build();
      //设置 Notification 的 flags = FLAG_NO_CLEAR
      //FLAG_NO_CLEAR 表示该通知不能被状态栏的清除按钮给清除掉,也不能被手动清除,但能通过 cancel() 方法清除
      //flags 可以通过 |= 运算叠加效果
      notification.flags |= Notification.FLAG_NO_CLEAR;
      mNotificationManager.notify(DEFAULT_NOTIFICATION_ID, notification);
      }

    /**

    • 设置FLAG_AUTO_CANCEL
    • 该 flag 表示用户单击通知后自动消失
      */
      private void sendFlagAutoCancelNotification() {
      //设置一个Intent,不然点击通知不会自动消失
      Intent resultIntent = new Intent(this, MainActivity.class);
      PendingIntent resultPendingIntent = PendingIntent.getActivity(
      this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
      .setSmallIcon(R.mipmap.ic_launcher)
      .setContentTitle(“Send Notification Use FLAG_AUTO_CLEAR”)
      .setContentText(“Hi,My id is 1,i can be clear.”)
      .setContentIntent(resultPendingIntent);
      Notification notification = builder.build();
      //设置 Notification 的 flags = FLAG_NO_CLEAR
      //FLAG_AUTO_CANCEL 表示该通知能被状态栏的清除按钮给清除掉
      //等价于 builder.setAutoCancel(true);
      notification.flags |= Notification.FLAG_AUTO_CANCEL;
      mNotificationManager.notify(DEFAULT_NOTIFICATION_ID, notification);
      }

    /**

    • 设置FLAG_ONGOING_EVENT
    • 该 flag 表示发起正在运行事件(活动中)
      */
      private void sendFlagOngoingEventNotification() {
      NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
      .setSmallIcon(R.mipmap.ic_launcher)
      .setContentTitle(“Send Notification Use FLAG_ONGOING_EVENT”)
      .setContentText(“Hi,My id is 1,i can’t be clear.”);
      Notification notification = builder.build();
      //设置 Notification 的 flags = FLAG_NO_CLEAR
      //FLAG_ONGOING_EVENT 表示该通知通知放置在正在运行,不能被手动清除,但能通过 cancel() 方法清除
      //等价于 builder.setOngoing(true);
      notification.flags |= Notification.FLAG_ONGOING_EVENT;
      mNotificationManager.notify(DEFAULT_NOTIFICATION_ID, notification);
      }
      }

Notification 通知效果的设置方式及注意事项,代码如下:
/**

  • 最普通的通知效果
    */
    private void showNotifyOnlyText() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setLargeIcon(mLargeIcon)
    .setContentTitle(“我是只有文字效果的通知”)
    .setContentText(“我没有铃声、震动、呼吸灯,但我就是一个通知”);
    mManager.notify(1, builder.build());
    }

/**

  • 展示有自定义铃声效果的通知
  • 补充:使用系统自带的铃声效果:Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, “6”);
    */
    private void showNotifyWithRing() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(“我是伴有铃声效果的通知”)
    .setContentText(“美妙么?安静听~”)
    //调用系统默认响铃,设置此属性后setSound()会无效
    //.setDefaults(Notification.DEFAULT_SOUND)
    //调用系统多媒体裤内的铃声
    //.setSound(Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,“2”));
    //调用自己提供的铃声,位于 /res/values/raw 目录下
    .setSound(Uri.parse(“android.resource://com.littlejie.notification/” + R.raw.sound));
    //另一种设置铃声的方法
    //Notification notify = builder.build();
    //调用系统默认铃声
    //notify.defaults = Notification.DEFAULT_SOUND;
    //调用自己提供的铃声
    //notify.sound = Uri.parse(“android.resource://com.littlejie.notification/”+R.raw.sound);
    //调用系统自带的铃声
    //notify.sound = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,“2”);
    //mManager.notify(2,notify);
    mManager.notify(2, builder.build());
    }

/**

  • 展示有震动效果的通知,需要在AndroidManifest.xml中申请震动权限
  • 补充:测试震动的时候,手机的模式一定要调成铃声+震动模式,否则你是感受不到震动的
    */
    private void showNotifyWithVibrate() {
    //震动也有两种设置方法,与设置铃声一样,在此不再赘述
    long[] vibrate = new long[]{0, 500, 1000, 1500};
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(“我是伴有震动效果的通知”)
    .setContentText(“颤抖吧,凡人~”)
    //使用系统默认的震动参数,会与自定义的冲突
    //.setDefaults(Notification.DEFAULT_VIBRATE)
    //自定义震动效果
    .setVibrate(vibrate);
    //另一种设置震动的方法
    //Notification notify = builder.build();
    //调用系统默认震动
    //notify.defaults = Notification.DEFAULT_VIBRATE;
    //调用自己设置的震动
    //notify.vibrate = vibrate;
    //mManager.notify(3,notify);
    mManager.notify(3, builder.build());
    }

/**

  • 显示带有呼吸灯效果的通知,但是不知道为什么,自己这里测试没成功
    */
    private void showNotifyWithLights() {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(“我是带有呼吸灯效果的通知”)
    .setContentText(“一闪一闪亮晶晶~”)
    //ledARGB 表示灯光颜色、 ledOnMS 亮持续时间、ledOffMS 暗的时间
    .setLights(0xFF0000, 3000, 3000);
    Notification notify = builder.build();
    //只有在设置了标志符Flags为Notification.FLAG_SHOW_LIGHTS的时候,才支持呼吸灯提醒。
    notify.flags = Notification.FLAG_SHOW_LIGHTS;
    //设置lights参数的另一种方式
    //notify.ledARGB = 0xFF0000;
    //notify.ledOnMS = 500;
    //notify.ledOffMS = 5000;
    //使用handler延迟发送通知,因为连接usb时,呼吸灯一直会亮着
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
    @Override
    public void run() {
    mManager.notify(4, builder.build());
    }
    }, 10000);
    }

/**

  • 显示带有默认铃声、震动、呼吸灯效果的通知
  • 如需实现自定义效果,请参考前面三个例子
    */
    private void showNotifyWithMixed() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(“我是有铃声+震动+呼吸灯效果的通知”)
    .setContentText(“我是最棒的~”)
    //等价于setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
    .setDefaults(Notification.DEFAULT_ALL);
    mManager.notify(5, builder.build());
    }

/**

  • 通知无限循环,直到用户取消或者打开通知栏(其实触摸就可以了),效果与FLAG_ONLY_ALERT_ONCE相反
  • 注:这里没有给Notification设置PendingIntent,也就是说该通知无法响应,所以只能手动取消
    */
    private void showInsistentNotify() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(“我是一个死循环,除非你取消或者响应”)
    .setContentText(“啦啦啦~”)
    .setDefaults(Notification.DEFAULT_ALL);
    Notification notify = builder.build();
    notify.flags |= Notification.FLAG_INSISTENT;
    mManager.notify(6, notify);
    }

/**

  • 通知只执行一次,与默认的效果一样
    */
    private void showAlertOnceNotify() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(“仔细看,我就执行一遍”)
    .setContentText(“好了,已经一遍了~”)
    .setDefaults(Notification.DEFAULT_ALL);
    Notification notify = builder.build();
    notify.flags |= Notification.FLAG_ONLY_ALERT_ONCE;
    mManager.notify(7, notify);
    }

/**

  • 清除所有通知
    */
    private void clearNotify() {
    mManager.cancelAll();
    }
Android studio 28 通知栏报错Failed to post notification on channel "null" 今天老师上课上到通知,教材是第一行代码,可能教材上的源码太久了,我在用安卓9的时候,模拟器报错Failed to post notification on channel “null”,在网上查了很久才知道,Notification在android 26以上设置时,需要设置渠道信息才可以正常显示通知,这是 官方文档地址[https://developer.android.google.cn/abo... 阅读详情

相关推荐

实现Android常驻通知栏Notification的完整指南

Android Notification是Android系统中用于向用户显示应用状态更新的一种机制。它能够让应用在不打断用户当前操作的情况下,展示信息。随着Android版本的更新,Notification的管理和用户交互方式也发生了很大的变化。创建一个Notification Channel,首先需要定义一个Channel ID和Channel Name。Channel ID是一个字符串,用于在程序中唯一标识这个Channel。Channel Name是用户可见的名称,应简洁明了地描述通知的用途。

weixin_36073714的博客 1635

【Android】状态栏通知Notification、NotificationManager详解

在Android系统中,发一个状态栏通知还是很方便的。下面我们就来看一下,怎么发送状态栏通知,状态栏通知又有哪些参数可以设置?首先,发送一个状态栏通知必须用到两个类:  NotificationManager 、 Notification。NotificationManager :  是状态栏通知的管理类,负责发通知、清楚通知等。NotificationManager 是一个系统Service,必须通过 getSystemService()方法来获取。NotificationManager nm = (No

幻影浪子 11万+

密码学:一文看懂Base64算法

Base64常常在我们开发中出现,我们可能只知道它是一串乱码(看不懂的符号),知道有时候知道我们需要把一些数据进行base64编码,有时候需要进行Base64解码。但是却不知道它的作用是什么?它存在的意义是什么?还有它是如何生成的?如何编码和解码?上述的疑问相信在你读完本篇文章之后烟消云散。下面开始正文。Base64是什么?它和加密解密操作有什么关系吗?没错,这就是经过Base64编码后的字符串。对它解码后,我们获得以下内容点个关注,是对我持续创作的最大的鼓励!

Shujie 1万+

Android Notification通知的使用

Notification : 通知 一 使用大纲 1 获取通知栏管理 NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); 2 实例化通知栏构造器 Notification notification = new NotificationCompat.Builder() .setContentTitle() ...

m0_45877477的博客 740

用《Flappy Bird》游戏带你搞懂强化学习:从Q-learning到DQN的保姆级实战

本文通过《Flappy Bird》游戏实战,详细讲解了从Q-learning到DQN的强化学习技术。从环境搭建、Q表格构建到深度Q网络(DQN)的实现,逐步展示如何训练AI自主玩游戏。文章包含代码示例、训练技巧和性能优化方法,帮助读者深入理解强化学习的核心概念和应用。

weixin_42526415的博客 350

Ubuntu 22.04 LTS下Xenomai 3.3实时内核配置全攻略(附常见错误排查)

本文详细介绍了在Ubuntu 22.04 LTS系统上配置Xenomai 3.3实时内核的完整流程,包括环境准备、内核补丁应用、编译优化及常见错误排查。特别针对工业自动化和机器人控制场景,提供了性能优化建议和故障解决方案,帮助开发者实现毫秒级精度的实时任务处理。

weixin_29268385的博客 473

Notification使用以及PendingIntent.getActivity()

public void sendNotification(Context ctx,String message) { //get the notification manager String ns = Context.NOTIFICAT...

weixin_30555125的博客 250

STM32H743玩转以太网:不用FreeRTOS,手把手搞定LAN8742和DHCP(附MPU配置避坑指南)

本文详细介绍了在STM32H743裸机环境下实现以太网通信的完整方案,重点讲解了LAN8742 PHY芯片的配置和DHCP自动获取IP的实现。通过CubeMX配置、内存布局优化和MPU设置,避开了H7系列常见的Cache陷阱,提供了无操作系统环境下的高效网络通信解决方案。

weixin_42709044的博客 204

通知栏notification管理工具类【直接可用】

创建通知栏,适配8.0系统 final String CHANNEL_ID = "channel_id"; //通道渠道id final String CHANEL_NAME = "吉智警务通"; //通道渠道名称 NotificationChannel channel = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES...

fengyeNom1的博客 1551

Tessent --- PDL

当关联的ICL模块是当前ICL顶部模块时,即当它与当前设计匹配时,只能iCall一个iTopProc。但是,可以在iTopProc内调用iCall iProc或iTopProc。为指定后续iProc命令引用的ICL模块,发出这个命令之后,随后定义的iProc都会对应的ICL模块进行定义。为后续iCall调用,当使用iCall命令调用该过程时,参数列表中的变量将被替换为iCall命令中指定的值。在调用iProc时,运行iProc内的命令。PDL是面向工程师的,工程师利用PDL语言,对ICL中的单元进行控制。

qiantianyiqian的博客 2808

自学 ABAP 和自学 SAP 的差别

有朋友在我的 ABAP 学习教程里留言: > 自学SAP是不是都要搭建虚拟服务器,然后自己去官网下载新版本SAP就可以吗 对于初学者,我们要搞清楚 ABAP 和 SAP 的区别。 ABAP 是一门编程语言,SAP 首先是德国软件公司的名称,也代表这家公司开发的一系列软件。SAP 公司开发的软件,我们有时也称产品,其功能能满足客户一个或者多个领域的业务需求。这些不同领域,我们也称为不同的业务模块,比如 ERP,CRM,SRM,HR 等等。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 6880

Notification(Notification的通知栏常驻、各种样式、点击无效、禁止滑动删除、兼容低版本)

Notification(Notification的通知栏常驻、Notification的各种样式、Notification点击无效、Notification禁止滑动删除) Android的Notification是android系统中很重要的一个机制, 产品人员常常利用通知栏的方式,跟用户进行弱沟通。拥有推送通知的app要比没有此类功能的app活跃率要高很多。另外类似于墨迹天气,清理大师等ap...

周天祥的博客 11万+

网络层隧道技术之ICMP隧道(pingTunnel/IcmpTunnel)

目录 ICMP隧道 使用ICMP搭建隧道(PingTunnel) 使用ICMP搭建隧道(Icmptunnel) ICMP隧道 ICMP隧道简单实用,是一个比较特殊的协议。在一般的通信协议里,如果两台设备要进行通信,肯定需要开放端口,而在ICMP协议下就不需要。最常见的ping命令就是利用的ICMP协议,攻击者可以利用命令行得到比回复更多的ICMP请求。在通常情况下,每个ping命令都有相...

谢公子的博客 6707

安卓开发 通知栏Notification详解

安卓开发通知栏Notification的详细介绍和用法示例

wm 6959

2025华为杯第二十二届中国研究生数学建模竞赛E题:高速列车轴承智能故障诊断问题 - 完整解题分析+完整MATLAB源码!

🎓 本文收录于 《滚雪球学数学建模》专栏,本专栏专注于从零基础出发,带你循序渐进掌握数学建模的核心方法与思维路径。通过“滚雪球式”学习法,从最简单的生活化案例到经典建模工具,再到省赛、国赛真题实战演练,逐步积累知识与技能,帮助你搭建完整的建模体系。无论你是刚接触建模的新生,还是希望提升科研与竞赛能力的学者与工程师,本专栏都将为你提供一条清晰、高效、可实操的建模成长路线,助力你快速进阶,突破难点,迈向数学建模竞赛与实际应用的更高峰 🚀!

**My Coding Family** 2016

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

安卓Notification通知栏全解

全栈工程师开发手册 (作者:栾鹏) 安卓教程全解 安卓通知栏是提醒用户信息有效手段,也是通过用户的行为触发事件服务的方式。 Notification允许在当前应用程序不活动或不可见时向用户发送信号。 创建通知栏有使用Notification直接创建何使用Notification.Builder创建两种方法 1、使用Notification直接创建通知栏 private

1869

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Android通知栏-Notification(通知消息)

1.概述 当应用程序在后台运行,希望向用户发出一些提示学习,就需要借助Notification(通知)来实现。在发出一条通知后,手机最上方的状态栏会显示一个通知的图标,下拉状态栏后就可以看到通知的详细内容。 1.1 视图分类 Notification有两种视觉风格,一种是标准视图(Normal View),另外一种是大视图(Big view)。标准视图在Android中各...

云上道人的博客 4万+

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

通知栏如何更新android,安卓状态栏通知Notification方法更新(setLatestEventInfo)

今天使用安卓状态栏通知的时候,发现Notification的setLatestEventInfo构造方法画上的横线,也就是以前版本的方法,将要舍弃,强迫症没办法啊,于是查询资料找到了最新的构造方法,留存下吧。Notification notification = new Notification.Builder(context).setContentTitle("标题")//设置通知标题.setC...

weixin_35131425的博客 1330

android实现通知,Android中的3种通知Notification

Android中的Notification分为三种:1、普通Notification2、折叠Notification3、悬浮Notification1、普通Notification//普通通知val mIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://blog.csdn.net/qq_40716430/article/details/10...

weixin_42347869的博客 834

Android发送通知——通知栏(Notification)

通知是指 Android 在您应用的界面之外显示的消息,旨在向用户提供提醒、来自他人的通信信息或您应用中的其他实时信息。在发出一条通知后,手机最上方的状态栏会显示一个通知的图标,下拉状态栏后就可以看到通知的详细内容。用户可以点按通知来打开应用,或直接从通知中执行操作。

weixin_43977664的博客 1万+

Android-Notification安卓手机通知栏通知的开发

一、概述           Notification是显示在手机状态栏的消息(手机状态栏位于手机最顶端),代表一种全局效果的通知。 二、通知栏的内容        图标、标题、内容、时间、点击后响应 三、实现通知栏      (1)获取NotificationManager。      (2)显示通知栏:notify(id, notification);      (3)取消通知栏

雨泪不轻扬 1578

安卓中Notification通知的详解

这是关于androidNotification的详解,希望可以帮助到大家

知他人之所知,晓他人之不晓。 2217

Android的notification通知

概括: Android使用notification实现消息提醒,提供通知栏和通知抽屉查看通知和通知详情,Android的notification机制应用非常广泛,是指在应用程序之外显示的消息,布局由系统模板决定,开发者只需要定义模板中各部分的内容,通知详情就会在点开后展开视图显示设置的内容。 目前大体分为状态栏图标通知、悬挂提醒式通知、锁屏通知及圆点通知,从Android8.0开始必须为所有通知分配一个或多个通道,否则通知将不会显示。Android8.0及以上通过通道的importance属性设置重要性

weixin_51872136的博客 3638

安卓中通知(Notification)的基本使用方法

安卓中通知(Notification)的基本使用方法 1. 通知的使用场合  当某个应用程序希望向用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知来实现。发出一条通知后,手机最上方的状态栏中会显示一个通知的图标,下拉状态栏后可以看到通知的详细内容。  2. 通知的创建步骤    (1)获取NotificationManager实例,可以通过调用Co

dotedy的博客 595

android之Notification通知

<br />我们在用手机的时候,如果来了短信,而我们没有点击查看的话,是不是在手机的最上边的状态栏里有一个短信的小图标提示啊?你是不是也想实现这种功能呢?今天的Notification就是解决这个问题的。<br />package cn.com.chenzheng_java; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import an

梦中一夜下江南 5万+

安卓开发--通知Notification

先在AndroidManifest.xml里面添加权限。必须提供,显示在状态栏(纯白色,推荐使用矢量图)VISIBILITY_SECRET:完全不显示。Android 8.0+ 必须为通知分配渠道。VISIBILITY_PUBLIC:完全显示。可选,展开后显示(通常用于联系人头像)小图标 (Small Icon)大图标 (Large Icon)决定通知的显示位置和干扰程度。渠道 (Channel)构建兼容不同版本的通知。13.通知的可见性控制。状态栏显示+默认声音。

m0_50891221的博客 402
上一篇: Android-StateListDrawable(状态选择器)
下一篇: Android-主题和样式
Android_xi
博客等级 码龄8年 4粉丝 59原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值