简体   繁体   中英

Little Symbol in Notification Icon

can somebody tell me how to get rid of the little Symbol in the Notification Icon?

    Bitmap icon = BitmapFactory.decodeResource(mainact.getResources(),R.mipmap.ic_launcher);
    Notification notification = new NotificationCompat.Builder(mainact, "Channel1")
            .setLargeIcon(icon)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("NotifyBlock")
            .setContentText("All notifications are blocked.")
            .setOngoing(true)
            .build();

    notificationManager.notify(1, notification);

Picture

I think is a custom notification layout, with badge.

You should do something like this:

create new layout custom_push.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="72dp"
    android:padding="10dp" >
    <FrameLayout
        android:id="@+id/frame"
        android:layout_alignParentLeft="true"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:src="@mipmap/ic_launcher"
            android:id="@+id/image"
            android:adjustViewBounds="true"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_margin="8dp" />
            <ImageView
                  android:adjustViewBounds="true"
                  android:scaleType="fitCenter"
                  android:src="@android:drawable/btn_star"
                  android:layout_gravity="bottom|end"
                  android:tint="@color/colorAccent"
                  android:layout_width="16dp"
                  android:layout_height="16dp"/>
    </FrameLayout>

    <TextView
        android:textSize="13dp"
        android:textColor="#000"
        android:text="Testing"
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/frame"
        />
    <TextView
        android:textSize="13dp"
        android:textColor="#000"
        android:text="Testing is awecome"
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/frame"
        android:layout_below="@id/title"
        />
</RelativeLayout>

the next step call this method when you need:

    private void showNotification() {
    String CHANNEL_ID = "ChannelID";
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);


    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        String descriptionText = "Notification Channel";
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_ID, NotificationManager.IMPORTANCE_DEFAULT);
        channel.setDescription(descriptionText);
        // Register the channel with the system
        notificationManager.createNotificationChannel(channel);
    }


    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_push);
    contentView.setImageViewResource(R.id.image, R.mipmap.ic_launcher);
    contentView.setTextViewText(R.id.title, "Custom notification");
    contentView.setTextViewText(R.id.text, "This is a custom layout");

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
            .setSmallIcon(R.drawable.ic_push_icon)
            .setContent(contentView);

    Notification notification = mBuilder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;
    notificationManager.notify(1, notification);
}

And you can see something like this在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM