I want to show an icon on status bar when receive some messages.
The icon represent the number of unread message, so I want to draw some text, such as 2 on the icon.
I tried two solutions but both failed.
set number field (in notification class) as 2 , it seemed this is not supported after android 3.0
set remoteviews on statusbar, using framelayout in remoteViews, but failed.
statusbar only show icon, do not show overlayed text.
How can I implement this feature on android 4.1.2?
thanks in advance.
Use RemoteView in notification. Refer this Link
You should go for BadgeView. It gives you notifications that resemble facebook like numbers
You can't do it generally (as you discovered, support for badging the small icon with a number was dropped in Honeycomb since in most cases it made the underlying icon hard to see and understand).
If you feel you must do this, I'd suggest generating 10 or so images with the number embedded into the graphic. For the last one you'd do something like "*" or "9+" to indicate that there are too many updates to be enumerated in such a tight space :)
Related
[Question about android style]
I was wondering what is a good way to make clear that you can click on a telephone number and immediately call someone without copying & pasting the phone number.
How can I persuade a user to click on a phone number ?
ps: my question is not about how to call someone when clicking on a phone number, but about how to style the phone number to show that it is clickable.
Maybe putting small phone icon beside number would be clear for user.
Usually when the number is underlined like a HTML link, they understand right away.
TextView numberText = (TextView) findViewById(R.id.event_number);
numberText.setText("123-456-7890");
Linkify.addLinks(numberText, Linkify.PHONE_NUMBERS);
Checked the official documentation but there is no such standard defined for the same. So it is now upto you.
Underlining the number is fine but does not go well with text blocks.
Using a different font color for the number will suit well. Using Blue is the trend;-)
But in the end it is about the design and color scheme of your app too. Seeing a number in different text color is enough a indicator that you can use it as a link
My Android app contains a custom slider control based on the SeekBar, and I want to attach a custom text phrase to my control to explain its use for Accessibility.
I have done this successfully using View.setContentDescription(text), and TalkBack correctly speaks the phrase when I request focus on my slider control from Activity.onCreate.
So far, so good. However, when I touch the control, which I believe sets the AccessibilityFocus on my Android API 16 test device, extra words are being added to the spoken phrase, i.e. '...seek control. 0 per cent'. I want to remove these additional words.
I have tried to eliminate them using event.getText().clear() in View.onInitializeAccessibilityEvent(event) without success. Echoing the event to LogCat reports the correct phrase in event.contentDescription and no entries in event.text, but the extra words appear both in the audio output from the device hardware and in the on-screen debug text displayed by Menu->Settings->Accessibility->TalkBack->Settings->Developer Settings->Display Speech Output.
Please can anyone suggest where the extra words are being added, and how to eliminate them?
Any constructive suggestions would be welcomed. Thanks.
Update
I can see that some Explore By Touch (initial single-tap) event on my custom control does not pass through either its onInitializeAccessibilityEvent or dispatchPopulateAccessibilityEvent methods as I am deliberately calling event.setContentDescription(null). Despite this, there is an AccessibilityEvent being generated with my custom control's ContentDescription, set in Activity.onCreate in code, plus the extra words I'm trying to eliminate.
I've also set an AccessibilityDelegate on my custom control's parent ViewGroup to give visibility of its onRequestSendAccessibilityEvent calls. This confirms that no event containing my ContentDescription is passing through.
This is very puzzling, and happens on both the emulator and real hardware with API 16. Any ideas?
You also need to override http://developer.android.com/reference/android/view/View.html#onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)
and set the contentDescription there.
If you want to remove the 0%, I would try to change the class in AccessibilityNodeInfo/AccessibilityEvent:
http://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html#setClassName(java.lang.CharSequence)
I believe that this is a bug in TalkBack, and have raised Google Eyes-Free issue #375, including example code.
Update: Google have now archived this. Link moved to: http://code.google.com/archive/p/eyes-free/issues/375
I have seen some apps for which push notifications only display the app icon on the left and the message content on the right, with no title nor time. Also the message content takes the entire space and can occupy up to 3 lines.
.
When I don't supply any title nor text, my message still appears below where the title and time should be. It can only occupy one line and ends up showing only the beginning, with some ellipsis at the end.
I already looked at BigView and BigTextStyle, but it doesn't look like it's what I want, as even if I don't supply a title nor time, the notification message doesn't move up. Also I don't want the user to have to expand the notification to see the whole text.
Is there any simple way to achieve what I want? Or do I have to create a custom layout? I'm using Phonegap and have very limited Android knowledge.
Here is the code I'm currently using: https://github.com/phonegap-build/PushPlugin/blob/master/src/android/com/plugin/gcm/GCMIntentService.java (see the createNotification method).
I wasn't able to find any easy way to do that, like tweaking existing objects. I guess it always requires creating a CustomNotification, which I did: I created a RemoteViews to display things exactly the way I wanted.
I've seen several apps that show no text below the icon in the home screen, and i want that for my app.
By searching here, I managed to prevent the app name to appear below the icon with the manifest, but I still get a small grey empty oval.
Does anyone knows how to remove it also?
Thanks!
You should always include a label under the icon. I can't think of ANY reason why you wouldn't.
Is there a way to get the body text of a notification to scroll along the notification?
If this text is too long it just fades out at the border near the time. Is there a way to make it scroll slowly along so that someone could read it while in the notification drop down menu without having to either read it when it ticks along the status bar when it is received, but without going into the app?
I think this would be possible with a custom notification layout that housed XML with scrolling views, but i cannot use a custom layout, the notifications need to be created through the default notification creator.
Anyone know if this is possible?
Edit: im in no way affiliated with Onavo Lite, it was just a image i found to point out the text area i want to manipulate.
No, the default notification layout uses TextViews with a maximum size and no scrolling features.