DEV Community

MD. SABBIR HOSHEN HOWLADER
MD. SABBIR HOSHEN HOWLADER

Posted on

how to I can show notification text on icon place android studio

I am trying to create an Android application. For that, I want to show a notification in a specific place. So, I use RemoteViews. But now, I also want to display that text on my home screen. How can I do that?

Here is some breakdowns of my code:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<!-- TextView for displaying speed -->

<TextView
    android:id="@+id/text_speed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginStart="37dp"
    android:layout_marginTop="7dp"
    android:padding="10dp"
    android:text="70kb"
    android:textColor="@android:color/black"
    android:textSize="16sp" />

<TextView
    android:id="@+id/text_fmobile"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@id/text_speed"
    android:layout_marginStart="212dp"
    android:layout_toEndOf="@id/text_speed"
    android:text="speed : 70kb"
    android:textColor="@android:color/black"
    android:textSize="16sp" />

</RelativeLayout>
Enter fullscreen mode Exit fullscreen mode

and I use this java code for update and show those information

notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
            .setSmallIcon(R.drawable.ic_launcher_background)
            .setContentIntent(pendingIntent)
            .setSound(null) // Set notification sound to null to make it silent
            .setCustomContentView(notificationLayout);
Enter fullscreen mode Exit fullscreen mode

I want to show this application icon like that
Image description on my home screen

that now looks like that

Image description

provide me some advice that how to I can do that using those Layout Activity

Top comments (0)