Android(安卓)Notification 例子
16lz
2022-07-25
此代码经测试后不会抛出参数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);}}
更多相关文章
- mybatisplus的坑 insert标签insert into select无参数问题的解决
- Python技巧匿名函数、回调函数和高阶函数
- python list.sort()根据多个关键字排序的方法实现
- android EditText设置不可写
- android 使用html5作布局文件: webview跟javascript交互
- android studio调试c/c++代码
- IM-A820L限制GSM,WCDMA上网的原理(其他泛泰机型可参考)7.13
- 锁屏界面
- android(NDK+JNI)---Eclipse+CDT+gdb调试android ndk程序