public class MessageShowUtil {
private NotificationManager manager;
private Intent intent;
private PendingIntent pendingIntent;
private Notification notification;
private Context context;
public MessageShowUtil(Context context)
{
this.context=context;
//创建NotificationManager 实例
manager=(NotificationManager)context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
}
public void showMessage()
{
//创建Intent
intent = new Intent(context, MainActivity.class);
//点击通知的时候跳转Activity
pendingIntent = PendingIntent.getActivity(context, 0,intent, 0);
//创建消息
notification=new Notification();
//设置通知在状态栏显示的图标
notification.icon = R.drawable.icon;
//当我们点击通知时显示的内容
notification.tickerText = "開始登陸系統...........";
//通知时发出默认的声音
notification.defaults = Notification.DEFAULT_SOUND;
//设置通知显示的参数
//设置消息显示内容
notification.setLatestEventInfo(context, "公司信息", "点击查看信息!", pendingIntent);
//发布消息
manager.notify(0, notification);
}
}
我是这么理解的,呵呵