WEB开发网
开发学院手机开发Android 开发 Android Notification 例子 阅读

Android Notification 例子

 2010-07-04 23:48:00 来源:WEB开发网   
核心提示:此代码经测试后不会抛出参数IllegalArgumentException异常Java代码private void notification() {try {mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVIC

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

Java代码

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);

}

}

Tags:Android Notification 例子

编辑录入:coldstar [复制链接] [打 印]
赞助商链接