In samsung galaxy tab 2 when phone app goes to background, we can interact with phone app from notification. it has all the buttons and information that we need.
How can i implement notification like this?
First of all you can add functional buttons to your Notification just on devices running Honeycomb or later. Yes, some pre Honeycomb devices have those kind of Notifications, but only the device manufacturers were able to build such Notifications (examples for Dialer or Music Player).
To use such a notification you could use a customView for your Notification (have a look at RemoteViews).
An easier way,(and the recommended way) would be to use NotificationCompat.Builder and use the addAction method, wich will add a button to your Notification and execute the PendingIntent that you specify, when that button is clicked. This will also work on pre Honeycomb devices, meaning that on older devices will not show the button.
EDIT: you can refer to this great tutorial from Vogella : Android Notifications.
Related
I'm creating local push notifications, which is working fine. If the user has more than three open push notifications, the device (Samsung tablet) is grouping them together. Now the issue begins. If the user taps on the group notification summary my app is opened like it was never started (but it is running in foreground at the moment).
The OnCreate() method of MainActivity is called, which in turn calls LoadApplication(new App()); and in App.xaml.cs my first page is pushed on to the navigation stack.
If I expand the summary, I can click the separate push notifications and OnNewIntent() is called like desired.
I tried to add LaunchMode = LaunchMode.SingleTop to the MainActivity, but it didn't change something. Then I tried to use ActivityFlags.SingleTop, when creating the notification with the same result
How can I improve the behavior so that it doesn't push a new page onto the view?
Most likely it's because the Samsung Tablet has a version of >= Android N or API 7.0. You need to use Notification Groups (not Channel Groups since you mentioned it's not >8.0) in order to handle the opening of notifications properly.
Android can be difficult. Here's a good resource from the official android documentation on how to do that.
How you set the group and how you get the groupID on tapping the notification.
I am currently in a project which develops a DECT-based android system based on Android 5.0.1, and need to add a mode which will bring up the Dialer App while the InCallUi App is running (when there is an incoming call). When the Dialer App is in the foreground, there will be an annoying headsup notification from the InCallUi App showing the incoming call information displaying on the top of the screen.
I want to ask if there is a way to hide the headsup notification, while in locked-screen the notification entry can still be seen?
I have tried to change the priority of the notification, as indicated in the following link that the headsup notification only presented when the priority is set to HIGH, MAX and FULL_SCREEN: "If a notification's priority is flagged as High, Max, or full-screen, it gets a peeking notification.", but when I set the priority to LOW or MIN the headsup notification still shows:
https://material.google.com/patterns/notifications.html#notifications-behavior
Can anyone help? thanks:)
No, this was a security bridge on older versions of android that provided a way to services to run as ForegroundServices without the user knowing, that issue was fixed in android 4.4.
You can see this SO thread for more information.
Is there any way to prevent a notification be shown on Android Wear device? I know it's possible by using setOngoing(true) but I don't want my notification to be ongoing.
you should call setLocalOnly(true) on the NotificationCompat.Builder.
From the documentation
Set whether or not this notification should not bridge to other
devices.
you can read more here
Is it possible to create wearable notifications without using the notification builder?
I already create a notification via new Notification on newer devices and would like to keep that code and still add the Wearable notification to my existing one. Is this possible, or is everything connected to the builder helper class for now?
It seems that there is no WearableNotifications.Builder class anymore in the newest SDK.
But you need to do nothing to simply let your Notification show on Android Wear Devices.
If you want to have a slightly better look for your Notifications you can use WearableExtender to add Android Wear specific actions, pages and layout options.
The WearableNotifications.Builder class is only needed if you want to add 'wearable extensions' to your notification. The normal notifications shown by your app are displayed also on the wearable connected to your device without any further integration work.
As Notification.Compact is part of android support library, they should be supported on android 4.0 and below, but I'm not able to see inbox style notification in android 4.0 as well. It works perfectly on android 4.2.
Handling compatibility
Not all notification features are available for a particular version, even though the methods to set them are in the support library class NotificationCompat.Builder. For example, action buttons, which depend on expanded notifications, only appear on Android 4.1 and higher, because expanded notifications themselves are only available on Android 4.1 and higher.
To ensure the best compatibility, create notifications with NotificationCompat and its subclasses, particularly NotificationCompat.Builder. In addition, follow this process when you implement a notification:
Provide all of the notification's functionality to all users, regardless of the version they're using. To do this, verify that all of the functionality is available from an Activity in your app. You may want to add a new Activity to do this.
For example, if you want to use addAction() to provide a control that stops and starts media playback, first implement this control in an Activity in your app.
Ensure that all users can get to the functionality in the Activity, by having it start when users click the notification. To do this, create a PendingIntent for the Activity. Call setContentIntent() to add the PendingIntent to the notification.
Now add the expanded notification features you want to use to the notification. Remember that any functionality you add also has to be available in the Activity that starts when users click the notification.
refer to this Link