Android: Adding text from textView to status bar

Borys Zielonka

Is it possible to add the String taken from textView to Status Bar. I want to show text constantly , dynamically updated as textView from apps main activity.

TextView message = (TextView) findViewById(R.id.textView1);
message.setText("This I want to add to status bar");
Yauraw Gadav

Yes, you can

private static void generateNotification(Context context, String message) {
        int icon = R.drawable.ic_status;
        long when = System.currentTimeMillis();
        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(icon, message, when);
        String title = context.getString(R.string.app_name); // Here you can pass the value of your TextView
        Intent notificationIntent = new Intent(context, SplashScreen.class);
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent intent = PendingIntent.getActivity(context, 0,
                notificationIntent, 0);
        notification.setLatestEventInfo(context, title, message, intent);
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        notificationManager.notify(0, notification);
    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android: Adding text from textView to status bar

From Dev

Android Lollipop Set Status Bar Text Color

From Dev

Display Notification Text in Status Bar - Android

From Dev

Get text from expanded notification in status bar?

From Dev

Adding white status bar

From Dev

Custom App bar adding text and icons - Android

From Dev

How to overlay status bar and navigation bar from a Service? (android 4.4)

From Dev

getting text from a textview to display in a string in android

From Dev

Android - Get specific text from TextView

From Dev

Adding TextView to LinearLayout in Android

From Dev

PySide: How to change the status bar text from another class?

From Dev

adding a search box / text field to android's header bar

From Dev

Status bar color, Android

From Dev

Android status bar permissions

From Dev

adding geom_text from different dataset to geom_bar

From Dev

Animating text from left to right trims text in TextView Android

From Dev

Android app SDK: exclude status bar from transition's animation

From Dev

parse.com - Delete specific notification from status bar on android

From Dev

Android app SDK: exclude status bar from transition's animation

From Java

In iOS13 the status bar background colour is different from the navigation bar in large text mode

From Dev

Adding multiple values to a textView - Android

From Dev

Android : adding border around textview

From Dev

Android: adding programmatically a TextView is not working

From Dev

iPhone adding black space on the top of status bar

From Dev

Android - Set text to TextView

From Dev

Display text in textview in android

From Dev

Android TextView text alignment

From Dev

Wrap Text - Android TextView

From Dev

Android - TextView with dynamic text

Related Related

  1. 1

    Android: Adding text from textView to status bar

  2. 2

    Android Lollipop Set Status Bar Text Color

  3. 3

    Display Notification Text in Status Bar - Android

  4. 4

    Get text from expanded notification in status bar?

  5. 5

    Adding white status bar

  6. 6

    Custom App bar adding text and icons - Android

  7. 7

    How to overlay status bar and navigation bar from a Service? (android 4.4)

  8. 8

    getting text from a textview to display in a string in android

  9. 9

    Android - Get specific text from TextView

  10. 10

    Adding TextView to LinearLayout in Android

  11. 11

    PySide: How to change the status bar text from another class?

  12. 12

    adding a search box / text field to android's header bar

  13. 13

    Status bar color, Android

  14. 14

    Android status bar permissions

  15. 15

    adding geom_text from different dataset to geom_bar

  16. 16

    Animating text from left to right trims text in TextView Android

  17. 17

    Android app SDK: exclude status bar from transition's animation

  18. 18

    parse.com - Delete specific notification from status bar on android

  19. 19

    Android app SDK: exclude status bar from transition's animation

  20. 20

    In iOS13 the status bar background colour is different from the navigation bar in large text mode

  21. 21

    Adding multiple values to a textView - Android

  22. 22

    Android : adding border around textview

  23. 23

    Android: adding programmatically a TextView is not working

  24. 24

    iPhone adding black space on the top of status bar

  25. 25

    Android - Set text to TextView

  26. 26

    Display text in textview in android

  27. 27

    Android TextView text alignment

  28. 28

    Wrap Text - Android TextView

  29. 29

    Android - TextView with dynamic text

HotTag

Archive