标题未显示使用自定义通知

时间:2018-01-04 10:12:29

标签: android android-notifications android-remoteview

我在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());

1 个答案:

答案 0 :(得分:0)

使用 - :

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