1

I am creating one notification application.

But application require text instead of icon/image.

Reference image:http://tinypic.com/view.php?pic=23hu5xd&s=6

I am using this way to create notification all of the work fine but require text on status bar.

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher) .setContentTitle("hiii") // title for notification .setContentText("Hello word") // message for notification .setAutoCancel(false); // clear notification after click Intent intent = new Intent(this, MainActivity.class); PendingIntent pi = PendingIntent.getActivity(this, 0, intent,Intent.FLAG_ACTIVITY_NEW_TASK); mBuilder.setContentIntent(pi); mNotificationManager.notify(0, mBuilder.build()); 

Problem: how to set text instead of image. setSmallIcon(R.drawable.ic_launcher)

1 Answer 1

2

You have no choice but to set an image. You are welcome to have the image contain text.

In the screenshot you cited, the app probably has ~100 images to choose from for different percentage levels. You can organize those into a single LevelListDrawable, then use the two-parameter version of setSmallIcon() to indicate which level you want.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your quick response but i have always different text so how can i manage?
@Harshid: That is not possible. setSmallIcon() requires a resource, and you cannot create a resource at runtime.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.