android 发送提示消息

NotificationManager notificationManager
    = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);

 notification.defaults = Notification.DEFAULT_LIGHTS; 
         notification.icon = R.drawable.ic_action_search ;
         
         notification.flags |= Notification.FLAG_AUTO_CANCEL;
         notification.when = System.currentTimeMillis();
         notification.tickerText = message;  // 弹出消息提示信息

Intent in = new Intent(context,
                 Test.class);

         PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                 in, PendingIntent.FLAG_UPDATE_CURRENT);

         notification.setLatestEventInfo(context, "0.0.", message,
                 contentIntent);
         notificationManager.notify(new Random().nextInt(), notification);

猜你喜欢

转载自zyzzsky.iteye.com/blog/1715242