UI_通知

			public void onClick(View v) {
				Intent intent = new Intent(MainActivity.this,Second.class);
				PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 100, intent, PendingIntent.FLAG_CANCEL_CURRENT);
				NotificationManager manger = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
				// 构建 通知界面
				NotificationCompat.Builder builder = new NotificationCompat.Builder(
						MainActivity.this);
				builder.setContentTitle("通知");
				builder.setContentText("内容");
				builder.setContentIntent(pendingIntent);
				builder.setTicker("提示");
				builder.setWhen(System.nanoTime());
				builder.setSmallIcon(R.drawable.ic_launcher);
				manger.notify(0, builder.build());
			}

猜你喜欢

转载自blog.csdn.net/u013628092/article/details/83926709