0
我有一個通知,我想在創建後立即顯示。擴展通知
我的代碼現在:
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());
有了這個代碼,創建了通知,但它不是在屏幕上自動顯示。我需要掃描所有待處理的通知以搜索它。我想要的是,這個通知在創建後會自動顯示在屏幕上,有什麼建議嗎?