widget(10、Notification)

时间:2015-01-24 15:39:18   收藏:0   阅读:104

Notification即通知栏,在android中常用如下几种功能:

1、客户端功能提示,如版本升级;

2、收到短信、新闻等提示;

3、显示当前情况,如下载进度等;

Notification基本应用如下:

        Intent notifyIntent = new Intent(this, MainActivity.class);
        PendingIntent notify_Intent = PendingIntent.getActivity(this, 0,
                notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        
        mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        
        mNotification = new NotificationCompat.Builder(getApplicationContext())
        .setSmallIcon(R.drawable.ic_launcher)
        .setTicker("showNormal").setContentInfo("contentInfo")
        .setContentTitle("title").setContentText("content")
        .setNumber(1).setContentIntent(notify_Intent)
        .setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL)
        .build();
        
        mNotificationManager.notify(0, mNotification);

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!