ITeye博客

Android Notification 例子

fonter · 2010-07-03 09:20 · android · 移动开发 · Markdown

此代码经测试后不会抛出参数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);
		}
	}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。