notificationmanager

How do you change the output volume of a sound?

末鹿安然 提交于 2020-01-25 10:23:09
问题 I'm using this code to play a sound. I would like to give the user the ability to alter the volume of the sound. Can you tell me how to do this? NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(); notification.sound = Uri.parse("android.resource://emad/raw/quarter"); Thanks. Truly, Emad 回答1: use notification.audioStreamType = AudioManager.STREAM_MUSIC; context.setVolumeControlStream(AudioManager

NotificationManager.cancel() doesn't work: Notification isn't removed

本秂侑毒 提交于 2020-01-02 02:51:28
问题 I've been trying to remove a persistent Notification set by a Service using: startForeground(1337, notification); The code I'm using to cancel it: NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nManager.cancel(1337); // cancel existing service notification, doesn't take effect nManager.cancelAll(); //surpluous, but also doesn't take effect To clarify why I am doing this: the Service starts with a default persistent Notification.

Android alarm setting with specific date

给你一囗甜甜゛ 提交于 2019-12-29 01:06:05
问题 I wan to set alarm with notification at specific date. Then I am using AmarmManager with NotificationManager currently. When I set selected date from dateDialog, the alarm is working. How can I put calendar value on alarm set with fixed time? I want to repeat alarm every day on fixed time such as at 9:00 in the morning. Currently, alarm is ignoring the time on specific date. Could you help me? Many thanks. confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View

How to use notification with sound and vibration?

China☆狼群 提交于 2019-12-18 10:50:46
问题 How do you allow the device to vibrate or make a sound when a notification is launched. Ive heard of the FLAGS. But how would i use them for Sound and Vibration? 回答1: Edit In Android v4 support library, there is NotificationCompat.Builder and the method setSound which will work if using that class instead. However, the info below will still work. Notification notif ... //create your notification notif.defaults |= Notification.DEFAULT_SOUND; notif.defaults |= Notification.DEFAULT_VIBRATE; That

NotificationManager.cancel(id) is not working inside a broadcast receiver

会有一股神秘感。 提交于 2019-12-18 03:32:30
问题 Android: I am trying to cancel a notification from the notification bar after a package being installed. What I am doing is the following: public class MyBroadcastReceiver extends BroadcastReceiver { private static final String TAG = "MyBroadcastReceiver"; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_PACKAGE_ADDED.equals(action)) { Uri data = intent.getData(); //some code goes here //get the id of the notification to

How to set click listener for notification?

佐手、 提交于 2019-12-17 10:46:13
问题 I am using the following code to launch a notification when a Service is started Via AlarmManager: nm = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); CharSequence from = "App"; CharSequence message = "Getting Latest Info..."; PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0); Notification notif = new Notification(R.drawable.icon, "Getting Latest Info...", System.currentTimeMillis()); notif.setLatestEventInfo(this, from, message,

TransactionTooLargeException while notify notification

跟風遠走 提交于 2019-12-12 23:36:45
问题 I have update time while recording in android, I using CountDownTimer and update to remote view on notification. I have optimized smallest data but still get TransactionTooLargeException. public void showNotificationRecording() { mRemoteViews = new RemoteViews(getPackageName(), R.layout.notify_recording_layout); mBuilder = new NotificationCompat.Builder(mContext); isSecretModeEnable = mSharePreferencesSettings.getBoolean(RecordSettings.SECRET_MODE, false); Log.d(TAG, "isSecretModeEnable " +

notificationManager get notification by Id

一笑奈何 提交于 2019-12-12 09:36:20
问题 Anyone know any way to get a notification by id? It's I want when get a new notification if it is still being shown in the status bar of Android want to get the information and add it to a new notification. Thank you. 回答1: NotificationManager doesn't give you a way to find existing notifications by ID. If you want to update a notification, post a new notification but use the same ID. It will either show it as new or update the existing notification with that ID. 回答2: You can get active

Notification restart my activity and pause button on notification

我的梦境 提交于 2019-12-12 04:35:54
问题 My notification get restart when i click on it by Status bar when i start my app it stream audio from server and show a notification until i don't clear it from status bar so my problem is when i click on my app notification it restart the activity and stop the streaming music.. so please suggests me solution for to stop restarting app again from notification and i want to show notification which stick on notification bar upto i exit from app Also I want to Show pause and Play button on

Notification not showing up using Android Auto

一世执手 提交于 2019-12-12 04:17:21
问题 I followed the tutorial on Udacity and the developer site for Android auto. I am using a DVU for testing. The notifications don't show up on the DHU but appears on the phone here is my code: Using GcmListenerService: final PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); final PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); Intent