我有一个通知,我想在创建后立即显示。
我现在的代码:
Intent myIntent = new Intent(WearRunActivity.this, ResultsActivity.class);
myIntent.putExtra("distance", distance);
myIntent.putExtra("time", chronometer.getText());
myIntent.putExtra("pace", pace);
myIntent.putExtra("speed", speedAc);
myIntent.putExtra("lSteps", leftSteps);
myIntent.putExtra("rSteps", rightSteps);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, myIntent, PendingIntent.FLAG_CANCEL_CURRENT);
//WearRunActivity.this.startActivityIfNeeded(myIntent, 1);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.card_icon)
.setContentTitle("REPORT")
.setContentText(chronometer.getText())
.setLargeIcon(BitmapFactory.decodeResource(
getResources(), R.drawable.card_icon))
.setAutoCancel(true)
.setContentIntent(pendingIntent);
notification_manager = NotificationManagerCompat.from(this);
notification_manager.notify(1, notificationBuilder.build());
使用此代码,通知已创建,但不会自动显示在屏幕上。我需要浏览所有待处理的通知来搜索它。我想要的是这个通知在创建后自动显示在屏幕上,有什么建议吗?