Notification的用法
来源:互联网 发布:一首歌火了网络歌手 编辑:程序博客网 时间:2024/05/21 16:14
Notification是通过NotificationManger来管理的发送通知
要记住一个服务System.NOTIFICATION_SERVICE
java代码
package com.phone.hty.myapplication;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;public class MainActivity extends AppCompatActivity { private NotificationManager mNm; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mNm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); } public void next(View view) { Intent intent = new Intent(this, TabActivity.class); PendingIntent pi = PendingIntent.getActivities(this, 0, new Intent[]{intent}, 0); Notification notification = new Notification.Builder(this) .setAutoCancel(true) .setTicker("小马哥来了") .setSmallIcon(R.drawable.aa) .setContentTitle("大好人") .setContentText("总打时手有点累,还好腰不酸,头不痛") .setWhen(System.currentTimeMillis()) .setContentIntent(pi) .build(); mNm.notify(0x123, notification); } public void cencel(View view) { mNm.cancel(0x123); }}
0 0
- Notification 的用法
- Notification 的用法
- android notification 的用法
- android notification的用法
- Notification的用法
- Notification的用法
- Notification的用法
- Notification的用法
- Notification的简单用法
- Notification的用法
- Notification的用法
- Notification的用法
- Notification的基本用法
- Notification的基本用法
- Android的Notification的用法
- Android中Notification的用法
- Notification的功能与用法
- Notification的功能与用法
- android LinearLayout分割线设置
- 协程
- 用C语言实现大小端判断
- PHP系统时区设置
- 在SAS中创建空数据集的几种方法
- Notification的用法
- for 循环中植入两个变量
- Android开发之ListFragment结合LoaderManager加载数据
- UVA 437The Tower of Babylon - 简单dp
- 标签嵌套规范、网站结构制作实例笔记
- Java基础 常见List实现原理 - ArrayList
- Codeforces 631C-Report
- 单例模式,只要一个就够啦!
- 告诫自己要有目标