我想显示一个只显示文字而不是图标的通知!
我只是尝试:
private void showNotification(String msg) {
try {
Intent intent = new Intent(this, Act.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
//set the notification
Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(msg)
.setAutoCancel(true)
.setSound(notificationSound)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
} catch (Exception exp) {
Log.e("xmn", exp.toString());
}
}
问题是通知永远不会发生。
答案 0 :(得分:0)
Android requires您的通知中包含以下内容:
因此,您必须在通知中显示一个图标。
答案 1 :(得分:0)
您可以使用RemoteViews设置自定义布局/只是文本视图或任何内容。 custom notification