案桌 通知欄 notification

public void showNotice(View view)
	{
		NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
		Notification nf = new Notification(R.drawable.ic_launcher, 
				"我是一個notification", System.currentTimeMillis());
		nf.flags = Notification.FLAG_AUTO_CANCEL; //自動取消
		Intent intent = new Intent();
		intent.setAction(Intent.ACTION_CALL);
		intent.setData(Uri.parse("tel:110"));
		PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,0);
		nf.setLatestEventInfo(this, "我是標題", "我是內容", pendingIntent);
		nm.notify(0, nf);
		//高版本適用;
		/*
		Notification.Builder builder = new Builder(this);
		builder.setContentText("我是notification內容");
		builder.setContentTitle("我是標題");
		builder.setSmallIcon(R.drawable.ic_launcher).
		setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
		Notification nf = builder.build();
		nm.notify(0, nf);*/
	}
相關文章
相關標籤/搜索