---
title: "Android Notification 例子"
author: "fonter"
date: "2010-07-03T09:20:04Z"
tags: []
categories: ["移动开发"]
slug: "android-notification"
draft: false
lastmod: "2010-07-03T09:22:23Z"
id: 704858
url: "https://fonter.iteye.com/blog/704858"
---

此代码经测试后不会抛出参数IllegalArgumentException异常

 

```
	private void notification() {
		try {
			mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
			Intent intent = new Intent(this, TaskManager.class);
			CharSequence appName = getString(R.string.app_name);
			Notification notification = new Notification(R.drawable.icon,
					appName, System.currentTimeMillis());
			notification.flags = Notification.FLAG_NO_CLEAR;
			
			CharSequence appDescription = getString(R.string.app_name) + " "
					+ getString(R.string.is_running);
			notification.setLatestEventInfo(Splash.this, appName,
					appDescription, PendingIntent.getActivity(getBaseContext(),
							0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
			mNotificationManager.notify(0, notification);

		} catch (Exception e) {
			mNotificationManager = null;
			Log.e("Splash", "Splash", e);
		}
	}
```