【问题标题】:Header not showing using Custom Notification使用自定义通知未显示标题
【发布时间】:2018-01-04 10:12:28
【问题描述】:

我在 Android Studio 中使用带有自定义通知的 RemoteViews。唯一的问题是我现在显示小图标和应用程序名称时遇到问题。

谢谢希望我说得有道理?

Intent notificationIntent = new Intent(mContext, CardDemoActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent pendingIntent = PendingIntent.getActivity(mContext,0,notificationIntent,0);
RemoteViews remoteView = new RemoteViews(mContext.getPackageName(), R.layout.notifcation_player);
remoteView.setImageViewResource(R.id.notif_appIcon, R.drawable.app_logo);
remoteView.setTextViewText(R.id.notif_playing, title);
remoteView.setTextViewText(R.id.notif_preacher, preacher);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
mBuilder.setSmallIcon(R.drawable.app_logo);
mBuilder.setContent(remoteView);
mBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(mContext.NOTIFICATION_SERVICE);
notificationManager.notify(1, mBuilder.build());

【问题讨论】:

标签: android android-notifications android-remoteview


【解决方案1】:

使用-:

mBuilder.setContentTitle("Your tilte");  //title for your project
mBuildersetContentText("Your message);//message you want to show

【讨论】:

  • 是的,伙计,我试过了,但它没有显示。我正在为通知使用自定义布局。
猜你喜欢
  • 2018-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-09
  • 1970-01-01
  • 2016-11-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多