Android开发————Notification学习笔记
来源:互联网 发布:淘宝企业店和旗舰店 编辑:程序博客网 时间:2024/06/10 03:26
构建Notification的Acitivity:
package com.person.radiogrouptest;import android.app.Activity;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Context;import android.os.Bundle;import android.view.View;import android.widget.Button;public class AtyUsingNotification extends Activity {private Button shownoti;private NotificationManager nm;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.aty_using_notification);nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);// 用特定的ID来取消掉通知--〉点击通知跳转到该界面之后消除显示的通知的方法nm.cancel(R.layout.aty_using_notification);shownoti = (Button) findViewById(R.id.shownoti);shownoti.setOnClickListener(new View.OnClickListener() {// 用getIntent()函数是获取当前Activity的Intent// 还可以传入其他Acitivity,但是需要指定名称@Overridepublic void onClick(View v) {// 创建一个消息,名称为Ticker Text,并且伴随显示时间,图标为amap_end;Notification send = new Notification(R.drawable.amap_end,"Ticker Text", System.currentTimeMillis());// 设置TickerText消息中的:标题、内容send.setLatestEventInfo(AtyUsingNotification.this, "标题", "内容",PendingIntent.getActivity(AtyUsingNotification.this, 1,getIntent(), 0));// 发送通知进行显示nm.notify(R.layout.aty_using_notification, send);}});}}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/shownoti" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Notification" /></LinearLayout>
0 0
- Android开发————Notification学习笔记
- Android开发————Notification学习笔记
- Android学习笔记——Notification
- Android学习——Notification
- android学习笔记——Notification消息提示
- Android开发——通知Notification
- android开发之Notification学习笔记
- Android学习笔记之——Notification.Builder类的用法
- Android学习笔记(7)—关于Service和Notification的体验
- Android课堂笔记——Notification通知栏
- 《Android开发自我知识整理——Notification简析》
- Android——Notification通知
- Android中的通知—Notification
- Android中的通知—Notification
- Android中的通知—Notification .
- Android中的通知—Notification
- Android—Notification通知详解
- Android中的通知—Notification
- linux C++ 信号量处理
- int main ( int argc, char** argv )的说明
- 做好创业准备是决定创业成败的关键
- 顺序表中静态顺序表的创建、插入和删除一个元素(源码分析)
- 黑马程序员_Windows服务
- Android开发————Notification学习笔记
- 6、自动挂载Automounter——autofs软件包
- 初级数据持久化
- 关于VLAN
- 数据库
- wincap网络数据包的捕获
- 私有保护方式
- Java 23种设计模式
- UVa 10130 SuperSale(DP_01背包)