2011.07.11(2)——— android 自定义Notification

参考:http://blog.csdn.net/ddna/article/details/5122083

自定义notification的方法:
protected void showNotification() {        // look up the notification manager service        NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);        // The details of our fake message        CharSequence from = "Joe";        CharSequence message = "kthx. meet u for dinner. cul8r";        // The PendingIntent to launch our activity if the user selects this notification        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,                new Intent(this, IncomingMessageView.class), 0);        // The ticker text, this uses a formatted string so our message could be localized        String tickerText = getString(R.string.imcoming_message_ticker_text, message);        // construct the Notification object.        Notification notif = new Notification(R.drawable.stat_sample, tickerText,                System.currentTimeMillis());        // Set the info for the views that show in the notification panel.        notif.setLatestEventInfo(this, from, message, contentIntent);        // after a 100ms delay, vibrate for 250ms, pause for 100 ms and        // then vibrate for 500ms.        notif.vibrate = new long[] { 100, 250, 100, 500};        // Note that we use R.layout.incoming_message_panel as the ID for        // the notification.  It could be any integer you want, but we use        // the convention of using a resource id for a string related to        // the notification.  It will always be a unique number within your        // application.        nm.notify(R.string.imcoming_message_ticker_text, notif);    }



tickerText:这个是显示在status line上的内容
from:这个是拉下来后 通知里面的标题
message:这个是通知里面的内容
PendingIntent:点击通知后执行的intent
notif.vibrate:默认是震动提醒 其他各种提醒方式见“参考”。

更多相关文章

  1. Android处理9.png文件流程
  2. Android(安卓)项目中集成 Flutter
  3. 识别你的手机 Android的属性系统
  4. android adb配置环境变量
  5. Android原生运行uniapp使用5+app创建项目时的SDK集成步骤(一)
  6. android如何隐藏通知栏和禁止横屏竖屏切换
  7. 【Android】Android(安卓)Parcelable 源码解析
  8. 关于Android环境配置SDK的问题Failed to fetch URL http://dl-ss
  9. AndroidManifest.xml里面的activity的几个属性简介

随机推荐

  1. Android(安卓)有两种办法可以监控SDCARD
  2. Android RelativeLayout和LinearLayout性
  3. Android 网络管理
  4. Android基础 : Android(安卓)ContentProv
  5. Android - 游戏中的声音
  6. 利用python自动清除Android工程中的多余
  7. Android虚拟机上安装apk(adb配置)
  8. 手把手教你:android调用系统相机、相册功
  9. 关于android语言切换后通知栏显示的问题
  10. Android中使用Makefile编译程序和库的方