Create a notification looks like the "Shuttle Player" Application - android

I'm creating a well customised Music Player for Android phone. The App will support devices from 4.0 so I would like to adapt the "Big Content View" for notifications. After searching around, I see the "Shuttle Player" app has exactly what I want. The features I want to add can be listed as follow:
Big view, with controllers and closing button.
2. Always on top of notification list, i.e even when a new notification comes (like new email), my app's ongoing notification will stay steady on top of them and the new one will come at the second position.
Actually both Google Music Player, CyannogenMod rom's Apollo player and Shuttle Player have the same notification layout, but I have tested the Apollo app and Shuttle Player and only the Shuttle Player does what I want to do..
I could add a remoteviews for the notification, but for the second feature, I still don't know how to adapt that idea. Anyone has experience in those thing? Please help!

Use setPriority() on your Notification.Builder to indicate relative priority. Higher-priority items will appear towards the top. However, you have no absolute guarantee of being at the top all of the time, as other high-priority notifications may be added.
Also, please allow this behavior to be configurable by the user. You may want your Notification to always be on top. The user may not. The user's opinion is more important than is yours.

Related

Use MediaButton to control foreground app (no audio) with audio in background

I want to use the media buttons to control a foreground app, but not for audio use.
So the goal is to detect button clicks to do certain things in the app.
I can achieve that by using MediaSession and the MediaButtonReceiver. see here
The problem is that when the app is used, often users play music in the background, so the audio focus of the background app takes over the MediaSession and i cannot control my app anymore.
Is there a way to achieve that? Directly listening for button clicks with onKeyDown does not seem to work.
sadly there is no way for two active MediaSessions at the same time. if another app is playing music and run MediaSession then yours doesn't have focus and isn't active... this is made for purpose - better UX - only one "player" app can play music (or video). if this wouldn't work like that and you could play music by few apps at once then how should work media button on e.g. headphones? pasuing/resuming all players? this is just not user-friendly, so Android team introduced MediaSession pattern with option for calling "focus on me now" by any app, but then another app/MediaSession pauses and doesn't get any inputs (this active session does)
if you need physical buttons presses then onKeyDown should work (inside Activity or eventually using AccessibilityService, which would work "globally" in whole system). if you need some on-screen notification buttons presses then just make custom layout for your notification with as much buttons as you like, even styled as a player
note that in Android 11 active MediaSessions notification is stickied to top of notification section when you drop down status bar. your custom notification will be somewhere below between all others (you can manipulate position a bit using priority param for notification/channel)

Telegram, notification sound

how to make the telegram's sound notification like an alarm, so that whenever there is a new post in the channel the phone keeps beeping like an alarm.
One possible solution on the iOS would be to forward messages from the channel (that's not mine, but I am a member) to my phone via SMS, as you can set a constant alarm for SMSes on iPhone.
I do not really have any better ideas on how to do this, so I am open to any clues that you can come up with. Maybe some of you know if there is any other way to achieve the same result on ios, android, windows phone or computer.
Thanks
To set a custom notification sound for any app, do as follows:
Settings : General : Apps & Notifications : App info
Now scroll to the app that you want to customise. In this case, select Telegram by pressing it.
Select "App notifications". Now you can select a default notification, but more particularly, you can pick a group or contact from the list.
The default setting for importance is "medium: no sound". Press that and change it to "Urgent" or "High". Go back one screen. Now you can select the sound, by pressing "Sound". Pick a sound, or add a custom sound by pressing "+" at the top right.
If you want to record something, like a voicetag that says "Telegram from Tom", simply move a recording of that into the "music" folder on your phone, select it as above and when a message comes in from Tom, you'll hear the message played.
These steps were taken on Android 8 on an LG G6, but should be similar for other phones. For older versions of Android this feature may not be available. IOS? Sorry, none around here.
You can also do this in the Telegram app: Screenshots below.
The channel members would need to set a specific alarm sound for the channel. There is no way the sender of a message (not even a bot) could modify the sound of a notification.

Notification badge/counter in control app

I am working on a control-based (V2.0) SW2 app. Is it possible to set the badge-number (i.e. the notification counter) on the icon in the application view used in a notification-based app? I do not need anything else from the notification API, I just want to be able to set the badge-number and removing it after the user opens the control-based app.
Thank you,
Andrej
Unfortunately that is not currently possible without using both the Control and Notification APIs together. If you use both of them in your extension you may be able to achieve something similar to what you want but with the limitation that the extension will always start in Notification mode (this is a bug in the current implementation) so you wouldn't be able to go straight into the Control part of your extension.

Is there any way to clear the Voicemail notification that was added by my app in ICS?

My app is using the new VoicemailContract functionality in ICS to insert voicemails that show up in the stock call log. I've got it working perfectly, but I can't figure out how to control the new Voicemail notification that pops up when the new voicemails are added. The notifications seem to be controlled by the Phone app, and even if I manually update the voicemail's IS_READ attribute, the notification doesn't go away. In fact, I can delete the voicemail altogether, and the notification doesn't go away. The only way that it goes away is if that notification is clicked, or if I manually go into the call log and open one of the new voicemails.
Does anyone have any idea on how to control that programmatically from my app?
Unfortunately you can't. Status bar notifications can only be cleared by the app that placed them there. The phone app is the app that placed it there and this is why only that app is able to clear it.
I wish there was a way to do this myself, but currently, there is not :(

Add Buttons Above the Notifications Tab in the Status Bar

I am developing an Android app that will run as a service most of the time. The user would be able to control it via the status bar -- including the ability to stop the service altogether.
Even though I am able to make a custom view and put buttons on the Notifications area [see Figure 1], I would like to be able to put it above the "Android"/Service Provider's name. Much in the same way as the Music Player app does this [see Figure 2]. That way, even if the user clears their notifications, my app's control panel will remain active as long as the service is running.
What's the best way to do that, please?
Original Image Link
Your ROM has hidden the Ongoing header; both the Music player and the hardware control widget use the ONGOING_EVENT flag to remain where they are (someone correct me if I'm wrong). Confirm this by loading your app onto your patched phone - the documentation specifically names e.g. Music players (and other times your process is still going on in the background) as times when you should use this flag.
You might like to note that the same page recommends the FLAG_NO_CLEAR flag - if all you want is for it not to be cleared when the user clicks clear notifications (this is recommended for ongoing apps).

Categories

Resources