android-notifications

Failed to post notification on channel “null” Target Api is 26

最后都变了- 提交于 2019-11-29 22:53:59
Two log showing 1: Use of stream types is deprecated for operations other than volume control 2: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case When you target Android 8.0 (API level 26), you must implement one or more notification channels to display notifications to your users. int NOTIFICATION_ID = 234; NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { String CHANNEL_ID

Android P Beta - AlarmManager Notifications not working

喜欢而已 提交于 2019-11-29 19:49:36
问题 I'm testing my application on Android P beta release 4. My app's targetSdkVersion is 27 It has been observed that alarm manager notifications are not working as expected. I'm using below code to set the notifications - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, AlarmIntentBuilder.buildPendingIntent(context, uri)); } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK

How to send notification from handheld to wear to open Activity on wear device

放肆的年华 提交于 2019-11-29 19:44:35
I'm wondering if it is possible to send notification from handheld (android phone) to wear device to open Activity on wear device? What I want to do is as following. So far, I checked the following documents, but it's different from what I want to do. Adding Wearable Features to Notifications What is described here is sending notification from phone to wear, then open activity on the phone (I want to open activity on the wear) Create Custom Notifications What is described here is sending notification from wear to wear, then open activity on the wear (I want to send notification from phone to

Android notification at specific date

孤街浪徒 提交于 2019-11-29 18:50:09
问题 I have to create an app in which I must set a date and at that specific date at 9 O'clock, I must give a notification. What is the simplest method of doing this? I want the app to work even when the app gets killed anyway. Is AlarmManager a solution? 回答1: To schedule an Action you can use the AlarmManager Try this code it's work for me: 1 / Declare the BroadcastReceiver CLASS to launch the Action, this class can be inside your activity or outside in an other java file public class Receiver

Is there a straightforward way to stop a service in response to a user clicking a notification?

心不动则不痛 提交于 2019-11-29 17:49:20
问题 I'd like the following behavior: The user clicks a notification and Android stops my Service. The problem is that stopping a Service requires a call to stopService and I cannot easily create a PendingIntent that does that. So the only way I found to do this is to have my Service receive a special Intent extra that causes the Service to call stopSelf and stop. Is there a simpler way to directly cancel a Service from a notification click? 回答1: You could create a simple BroadcastReceiver that

Lollipop Notification setVisibility() Does Not Work?

岁酱吖の 提交于 2019-11-29 16:49:36
问题 I am trying to write a demo of using setVisibility() to control what shows up on the Android 5.0 lockscreen for a Notification . However, there seems to be no effect: the default VISIBILITY_PRIVATE still shows the private Notification , not its public counterpart VISIBILITY_SECRET notifications still show up on the lockscreen IOW, everything behaves as though VISIBILITY_PUBLIC were in force, at least when I test on a Nexus 7 running the Android 5.0 image we were given shortly after Android 5

Android: Multiple Alarm not working

流过昼夜 提交于 2019-11-29 15:46:17
问题 In My application i have set the two alarm. On toogleButton on i am going to set it on with below code: case R.id.toggleButtonTwoMonth: myPrefs = this.getSharedPreferences("myPrefs",MODE_WORLD_WRITEABLE); if (tButtonTwoMonth.isChecked()) { Toast.makeText(getApplicationContext(), "Two months reminder is On", Toast.LENGTH_SHORT).show(); prefsEditor = myPrefs.edit(); prefsEditor.putBoolean("TwoMonth", true); prefsEditor.commit(); //For Broadcast Alarm Intent in = new Intent(this,

Android: is it possible to remove a system-managed notification programmatically?

♀尐吖头ヾ 提交于 2019-11-29 15:38:34
I've made an application that configure a vpn profile and connects to it. When I'm connected, I want just my notification to be shown, but android provides its own notification that is shown during the lifetime of a VPN connection. Is there anyway to "delete" that notification, or, at least, to delete the corresponding icon from the top of the screen? This is not possible on Android, sorry. You cannot control notifications outside of your own app, regardless of whether they belong to another third party app or the system. Only your own notifications may be updated or dismissed by you. 来源:

Cant cancel Notification using NotificationListenerService

 ̄綄美尐妖づ 提交于 2019-11-29 15:21:39
This is my service: public class Listener extends NotificationListenerService { Context context; @Override public void onCreate() { super.onCreate(); context = getApplicationContext(); } @Override public void onNotificationPosted(StatusBarNotification sbn) { String pack = sbn.getPackageName(); String ticker = sbn.getNotification().tickerText.toString(); Bundle extras = sbn.getNotification().extras; String title = extras.getString("android.title"); String text = extras.getCharSequence("android.text").toString(); Log.i("Msg",pack); Log.i("Msg",ticker); Log.i("Msg",title); Log.i("Msg",text);

Output: error: resource style/TextAppearance.Compat.Notification.Info (aka package_name:style/TextAppearance.Compat.Notification.Info) not found

前提是你 提交于 2019-11-29 13:34:53
After switching to Android Studio 3.2 canary I am getting the following build error. I have seen this post where the guy had a similar issue but no solution was mentioned over their. I want to try new material components and jetpack so is there any possibility where I don't have to switch back. com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed Output: error: resource style/TextAppearance.Compat.Notification.Info (aka com.nsnik.nrs.kotlintest.debug:style/TextAppearance.Compat.Notification.Info) not found. error: resource style/TextAppearance.Compat