当我将鼠标悬停在物体上时,按摩显示:
需要android.app.nofication找到android.app.notification.Builder
答案 0 :(得分:2)
应该是
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(MainActivity.this);
通常,整个代码都是这样的:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
notificationBuilder.setContentTitle("Title");
notificationBuilder.setContentText("Text");
notificationBuilder.setSmallIcon(R.mipmap.your_icon);
notificationBuilder.setTicker("Ticker");
notificationBuilder.setContentIntent(pendingIntent);
notificationBuilder.setAutoCancel(true);
NotificationManager nm = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(notificationID, notificationBuilder.build());
答案 1 :(得分:-1)
您忘记了.build();
像这样:
Notification noti=new Notification.Builder(MainActivity.this).build();