android-notifications

Handle three buttons click event in custom notification in android

孤街醉人 提交于 2019-12-21 06:45:00
问题 I have a custom notification with three buttons ("ok", "cancel", "later") I can catch click event only when there is one button, but with the three buttons i can't know which button of them is clicked. My question is "How to know which button is clicked?" // I use this code in My "createNotification" function to add event to buttons Intent intent = new Intent(Context.NOTIFICATION_SERVICE); PendingIntent pendinghomeIntent = PendingIntent.getBroadcast(getBaseContext(), 0, intent, 0);

How to get Override Do not Disturb Settings Value?

本小妞迷上赌 提交于 2019-12-21 03:46:07
问题 How do I get Override Do Not Disturb Settings state in Android for my own package app? 回答1: The documentation is not very clear how to show this option, just that it's possible: On Android 8.0 (API level 26) and above, users can additionally allow notifications through for app-specific categories (also known as channels) by overriding Do Not Disturb on a channel-by-channel basis. [...] On devices running Android 7.1 (API level 25) and below, users can allow notifications through on an app by

How to get Override Do not Disturb Settings Value?

社会主义新天地 提交于 2019-12-21 03:46:01
问题 How do I get Override Do Not Disturb Settings state in Android for my own package app? 回答1: The documentation is not very clear how to show this option, just that it's possible: On Android 8.0 (API level 26) and above, users can additionally allow notifications through for app-specific categories (also known as channels) by overriding Do Not Disturb on a channel-by-channel basis. [...] On devices running Android 7.1 (API level 25) and below, users can allow notifications through on an app by

NavUtils.shouldUpRecreateTask fails on JellyBean

社会主义新天地 提交于 2019-12-21 03:34:30
问题 I have an application that issues notifications that when selected start an activity. According to the Android docs I can use NavUtils.shouldUpRecreateTask to check whether the activity has been started directly (i.e. from the notification) or via a normal activity stack. However it gives the wrong answer. I'm testing this on JellyBean but using the support library. Basically shouldUpRecreateTask always returns false, even when the activity has been started form the notification. Any ideas on

Android Custom Notification doesn't Display

穿精又带淫゛_ 提交于 2019-12-21 03:16:07
问题 I'm having trouble getting a notification with a custom layout to display. If I use the following (old) code: notification = new Notification(); notification.icon = R.drawable.icon; notification.tickerText = currentTickerText; notification.when = System.currentTimeMillis(); notification.setLatestEventInfo(context, (CharSequence)currentTitle, (CharSequence)"", pendingIntent); Everything works as expected and the notification shows up. However if I use the following (new) code: contentView =

NotificationListenerService not reading text of stacked notifications

懵懂的女人 提交于 2019-12-20 23:49:08
问题 I hope this doesn't violate any rule as I've tried following the How-to-ask guide. I'm trying to read incoming notifications using NotificationListenerService and it works for me but only partially. The first notification of it's type, lets say - whatsapp I can get the ticker, text and title but then if the notifications stack up I no longer can read the text of the messages. How do I get the text of stacked up notifications? Here is the code I currently implement: public class

How to handle mixed RTL & LTR languages in notifications?

落花浮王杯 提交于 2019-12-20 23:29:32
问题 Background Android 4.3 has added a lot of support for RTL (Right-To-Left) languages, such as Hebrew and Arabic. The problem Even though there is "textDirection", "layoutDirection" and "gravity", I can't find the equivalents for the notification builder, not even in the compatibility library. This means that if there are Hebrew and English words together, the order is wrong. For example (and I write in English for simplicity) : Instead of "X called Y" , you get "Y called X" (suppose "called"

Android - Calling methods from notification action button

时光怂恿深爱的人放手 提交于 2019-12-20 08:49:48
问题 I know that you can launch Activities from the action buttons using PendingIntents. How do you make it so that the a method gets called when the user clicks the notification action button? public static void createNotif(Context context){ ... drivingNotifBldr = (NotificationCompat.Builder) new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.steeringwheel) .setContentTitle("NoTextZone") .setContentText("Driving mode it ON!") //Using this action button I would like to call logTest

Firebase token management in servers

守給你的承諾、 提交于 2019-12-20 07:13:19
问题 I still new with firebase and android notifications. I want to be able to send notifications to a single user based on some rules. What I've been reading so far is that a token can be generated with: FirebaseInstanceId.getInstance().getToken() Then, the token will need to be refreshed at some point when it expires. How to I set expiry for these tokens, if at all possible? If there are a thousand users having their tokens refreshed around the same time then I will need to do a thousand writes

setLatestEventInfo cannot be resolved

 ̄綄美尐妖づ 提交于 2019-12-19 19:48:23
问题 I am trying to do a notification on api level 10 and below is my code but im getting a syntax error setLatestEventInfo cannot be resolved. I am guessing its something to do with the API level public static void sendNotification(Context caller, Class<?> activityToLaunch, String title, String msg, int numberOfEvents, boolean sound, boolean flashLed, boolean vibrate, int iconID) { NotificationManager notifier = (NotificationManager) caller.getSystemService(Context.NOTIFICATION_SERVICE); final