nob*_*nux 6 android android-notifications
我正在尝试创建通知,而不使用NotificationCompat.Builder. 如果不是真正需要(以及出于教育目的),动机不是使用支持库,我认为这是可能的,因为有“本机”Notification和NotificationManager向用户公开的类。
我的尝试如下:
Intent i = new Intent();
i.setClassName("com.test", "com.test.SomeActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
notification.setLatestEventInfo(this, title, content,pi);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0 , notification);
Run Code Online (Sandbox Code Playgroud)
这段代码只是运行,但没有出现通知,并且notificationManager.notify()通常返回void.
| 归档时间: |
|
| 查看次数: |
775 次 |
| 最近记录: |