当前位置: 代码迷 >> Android >> Android Notification 事例
  详细解决方案

Android Notification 事例

热度:379   发布时间:2016-05-01 15:43:29.0
Android Notification 例子

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

?

?

?

  相关解决方案