• android Notification 的使用


    android Notification 的使用

    http://www.cnblogs.com/newcj/archive/2011/03/14/1983782.html

    Android 状态栏通知Notification用法

    http://www.pocketdigi.com/20100905/89.html

    android清除通知栏消息

    http://www.2cto.com/kf/201201/116590.html

     

    public class SmsNotification {
        public static void showSmsNotification(Context context) {
            List<TxrjMessage> list = SmsDataManager.getUnreadMessages(context);
            if(list.size()>0){
                notify(context, list.get(0));
            }
        }
        public static void notify(Context context, TxrjMessage msg) {
            NotificationManager notifiMgr = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            /*Notification notifi = new Notification(R.drawable.sms_icon,
                    "短信", System.currentTimeMillis());    */
            Notification notifi = new Notification();
            notifi.icon = R.drawable.sms_icon;
            notifi.tickerText = msg.getBody();
            notifi.when = System.currentTimeMillis();
            notifi.number = 1;
            /*notifi.flags = Notification.FLAG_ONGOING_EVENT
                    | Notification.FLAG_NO_CLEAR | Notification.FLAG_SHOW_LIGHTS;*/
            notifi.defaults = Notification.DEFAULT_ALL;
            Intent itNotifi = new Intent(context, MessageListActivity.class);
            String displayName = TextUtils.isEmpty(msg.getName()) ? msg.getNumber() : msg.getName();
            itNotifi.putExtra(TxrjConstant.EXTRA_THREAD_DISPLAY_NAME, displayName);
            itNotifi.putExtra(TxrjConstant.EXTRA_THREAD_NUMBER, msg.getNumber());
            PendingIntent pendIt = PendingIntent.getActivity(context,
                    TxrjConstant.REQUEST_READ_NOTIFICATION, itNotifi, 0);
            Log.i("txrjsms", "name:"+msg.getName()+", number:"+msg.getNumber());
            notifi.setLatestEventInfo(context, displayName, msg.getBody(), pendIt);
            notifiMgr.notify(0, notifi);
        }
    }

    Field-Type

    Field-Name

    Description

    public static final Creator<Notification>

    CREATOR

    Parcelable.Creator that instantiates Notification objects

    public int

    audioStreamType

    The audio stream type to use when playing the sound. Should be one of the STREAM_ constants from AudioManager.

    public RemoteViews

    bigContentView

    A large-format version of contentView, giving the Notification an opportunity to show more detail. The system UI may choose to show this instead of the normal content view at its discretion.

    public PendingIntent

    contentIntent

    The intent to execute when the expanded status entry is clicked. If this is an activity, it must include theFLAG_ACTIVITY_NEW_TASK flag, which requires that you take care of task management as described in the Tasks and Back Stackdocument. In particular, make sure to read the notification section Handling Notifications for the correct ways to launch an application from a notification.

    public RemoteViews

    contentView

    The view that will represent this notification in the expanded status bar.

    public int

    defaults

    Specifies which values should be taken from the defaults. To set, OR the desired from DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS. For all default values, use DEFAULT_ALL.

    public PendingIntent

    deleteIntent

    The intent to execute when the notification is explicitly dismissed by the user, either with the "Clear All" button or by swiping it away individually. This probably shouldn't be launching an activity since several of those will be sent at the same time.

    public int

    flags

     

    public PendingIntent

    fullScreenIntent

    An intent to launch instead of posting the notification to the status bar.

    public int

    icon

    The resource id of a drawable to use as the icon in the status bar.

    public int

    iconLevel

    If the icon in the status bar is to have more than one level, you can set this.

    public Bitmap

    largeIcon

    The bitmap that may escape the bounds of the panel and bar.

    public int

    ledARGB

    The color of the led.

    public int

    ledOffMS

    The number of milliseconds for the LED to be off while it's flashing.

    public int

    ledOnMS

    The number of milliseconds for the LED to be on while it's flashing.

    public int

    number

    The number of events that this notification represents.

    public int

    priority

    Relative priority for this notification.

    public Uri

    sound

    The sound to play.

    public CharSequence

    tickerText

    Text to scroll across the screen when this item is added to the status bar on large and smaller devices.

    public RemoteViews

    tickerView

    The view to show as the ticker in the status bar when the notification is posted.

    public long[]

    vibrate

    The pattern with which to vibrate.

    public long

    when

    A timestamp related to this notification, in milliseconds since the epoch.

  • 相关阅读:
    简单的Makefile
    共享库
    链接静态库
    /proc/uptime参数的意义
    磁盘挂载失败
    linux环境变量设置
    使用systemd-analyze 工具来分析各个服务进程的启动性能
    面试-2020C/C++后台开发深信服科技股份有限公司一面凉经(一问三不知,我是真的菜。。。)
    笔记-C/C++工程师面试笔记收集整理
    SpringCloud-分布式与集群的使用四(断路器Hystrix)
  • 原文地址:https://www.cnblogs.com/fengzhblog/p/3203127.html
Copyright © 2020-2023  润新知