android-pendingintent

android How to start activity when user clicks a notification?

寵の児 提交于 2020-01-21 00:54:40
问题 I wanna open activity when user clicks a notification. I know this question is duplicated but couldn`t find a solution here is what i did NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("My notification") .setContentText("Hello World!"); Intent resultIntent = new Intent(this, ResultActivity.class); // Because clicking the notification opens a new ("special") activity, there's // no need to create an

Notification passes old Intent Extras

元气小坏坏 提交于 2020-01-18 19:41:23
问题 i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200

Notification passes old Intent Extras

眉间皱痕 提交于 2020-01-18 19:38:38
问题 i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200

Notification passes old Intent Extras

[亡魂溺海] 提交于 2020-01-18 19:37:57
问题 i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200

Notification passes old Intent Extras

自作多情 提交于 2020-01-18 19:37:00
问题 i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200

Android pending Intent - Alarm - same code six(6) apps

倖福魔咒の 提交于 2020-01-17 14:01:21
问题 I found something strange yesterday. While testing app with localization versions(different apps-dif. packages, the same code) I found one interesting bug - the app sets alarm with the AlarmManager and pending Intent - when the broadcast is fired , only one app gets activated and executes the pending intent and all others apps(only different language) are not reacting at all. Is this android bug?? I'm expecting that the set Alarm will trigger every one app that has it's own set Alarm but

How do I stop playing sound by switching between toggle button?

血红的双手。 提交于 2020-01-17 12:18:15
问题 I have made an alarm clock and there I have used a toggle switch to start my alarm. What I want is as soon as the user click on the button again, it should stop the alarm (ring). Toggling between ON and OFF wil start and stop respectively. But right now, I am only able to start my alarm. In fact it never gets stopped. If I switch the button OFF the sound gets played even faster, that is very strange. How can I stop it? I have pasted the only part of code where I am assuming the problem occurs

notification intent opens the apps main activity in background if its paused

半城伤御伤魂 提交于 2020-01-17 06:28:08
问题 I have a notification service running that will create a notification for the user and if the user clicks the notification it opens an activity to display the message, the method I am using to create the notification is : public void createNotificationMsg(String name,String doing, boolean persistent){ PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), MessageNotificationActivity.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR

Android AlarmManager.cancel() not actually cancelling alarm/PendingIntent

青春壹個敷衍的年華 提交于 2020-01-17 04:11:48
问题 Trying to cancel an AlarmManager alarm, isn't quite working. I create a PendingIntent like so: static PendingIntent makePendingIntent(int id, Bundle bundle) { Intent intent = new Intent(mContext.getApplicationContext(), mfLocalNotificationManager.class); if(bundle != null) { intent.putExtra(BUNDLE_ID, bundle); } return PendingIntent.getBroadcast(mContext.getApplicationContext(), id, intent, PendingIntent.FLAG_UPDATE_CURRENT); } Called from SendLocalNotification: public static int

Stop pending intent

杀马特。学长 韩版系。学妹 提交于 2020-01-16 13:19:50
问题 I have one service which is running every 5 minutes so every 5 minutes service is started and do some work and then finish and again after 5 minutes it will be started because i have set interval time of repeat to 5 minutes Now if i want to stop that service and if i don't want to start service any more then what i have to do? Please help me? 回答1: You should perfrom cancel() on the pendingIntent. 来源: https://stackoverflow.com/questions/5754199/stop-pending-intent