如何在Android上的通知栏中显示结果
我正在创建一个Android应用程序。我要寻找的是在计算结果之后,我希望数值显示在通知窗口上。如何操作?要在通知中显示结果,您可以使用以下代码创建通知:如何在Android上的通知栏中显示结果,android,Android,我正在创建一个Android应用程序。我要寻找的是在计算结果之后,我希望数值显示在通知窗口上。如何操作?要在通知中显示结果,您可以使用以下代码创建通知: Bitmap icon = BitmapFactory.decodeResource(this.getResources(), R.drawable.noti_icon); NotificationCompat.Builder notificationBuilder = new NotificationComp
Bitmap icon = BitmapFactory.decodeResource(this.getResources(),
R.drawable.noti_icon);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.noti_icon)
.setLargeIcon(icon)
.setContentTitle("Your Title of Notification")
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
.setContentText("write here your score which you have counted");
Intent notificationIntent = new Intent(this, YourActivity.class); // here on notification click you are moved on this activity
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.setContentIntent(contentIntent);
Notification notification = notificationBuilder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.visibility |= Notification.VISIBILITY_PUBLIC;
notificationId = 0;
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, notification);
请分享您的源代码,这样我们至少可以了解您的当前状态并帮助您。好的先生。。。当然可以。如果你满意,就接受我的回答。(勾选箭头显示答案的左侧)