Android Notification用法
来源:互联网 发布:最好股指期货交易软件 编辑:程序博客网 时间:2024/05/19 02:27
package com.example.notificationtest;import android.os.Bundle;import android.app.Activity;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Intent;import android.view.Menu;import android.view.View;public class NotificationTestActivity extends Activity {static final int NOTIFICATION_ID = 0x123;NotificationManager nm;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_notification_test);nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.notification_test, menu);return true;}public void send(View Source){Intent intent = new Intent(NotificationTestActivity.this,OtherActivity.class);PendingIntent pi = PendingIntent.getActivity(NotificationTestActivity.this, 0, intent, 0);Notification notify = new Notification.Builder(this).setAutoCancel(true).setTicker("有新消息").setSmallIcon(R.drawable.ic_launcher).setContentTitle("一条新通知").setContentText("恭喜你,您加薪了!").setWhen(System.currentTimeMillis()).setContentIntent(pi).build();nm.notify(NOTIFICATION_ID,notify);}public void del(View v){nm.cancel(NOTIFICATION_ID);}}
0 0
- Android Notification 用法
- android notification 的用法
- android notification的用法
- Android Notification用法
- Android基础-Notification用法
- Android通知Notification用法
- Android Notification 用法
- android Notification简单用法
- Android中Notification的用法
- Android的Notification的用法
- android sdk --- Notification用法实例
- android app notification的用法
- Android Notification的多种用法
- android中Notification的用法
- android通知栏Notification用法
- Android Notification的多种用法
- Android Notification.setLatestEventInfo弃用和Notification.Builder用法
- Android Notification.setLatestEventInfo弃用和Notification.Builder用法
- MySQL开发规范
- CSS3 详解box-shadow
- notepad++自动补齐括号
- 移动互联网大环境下的精益创业,成功无处不在
- Xcode Code Snippets
- Android Notification用法
- Trapping Rain Water[leetcode]
- GitHub入门教程(一)- 安装
- 什么原因成就了一位优秀的程序员?
- Qt--圆形阴影边框
- 概述与杂谈【0001】CDC Better and better --Minrong 离别信
- 源码分析
- web.xml详解
- android完全退出程序的实践