Start Service from Notification

It is possible to start a service from a notification. You have to use PendingIntent.getService instead of pendingIntent.getActivity. Intent notificationIntent = new Intent(mContext, HandleNotificationClickService.class); PendingIntent pendingIntent = PendingIntent.getService(mContext, 0, notificationIntent, 0); Notification notification = new Notification(icon, tickerText,System.currentTimeMillis()); notification.setLatestEventInfo(mContext,contentTitle , contentText, pendingIntent); notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONGOING_EVENT; NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(CALLER_ID_NOTIFICATION_ID, notification);

How to get One Signal unique user id in Mobile?

Got the unique Id of OneSignal by using the following code which is in official site of OneSignal. OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() { @Override public void idsAvailable(String userId, String registrationId) { Log.d(“debug”, “User:” + userId); if (registrationId != null) Log.d(“debug”, “registrationId:” + registrationId); } }); Refer: Getting code in Official Site This Above Code is Deprecated. Please … Read more

How does Facebook Messenger clear push notifications from the lock screen if you’ve read them on desktop?

See the Multitasking Enhancements and the silent push notifications in particular. Using the silent push you can notify your app that new content is available and also download that content and/or set the badge number for example without displaying the notification in the “Notification Center”. You’ll have to set the UIBackgroundModes with the remote-notification value … Read more

How to execute a method by clicking a notification

After several iterations of trial and error, I finally found a fairly straightforward and clean way to run an arbitrary method when a notification’s action is clicked. In my solution, there is one class (I’ll call it NotificationUtils) that creates the notification and also contains an IntentService static inner class that will run when actions … Read more

CSS notification style badge over image

Bunch of different ways you can accomplish this. This should get you started: .item { position:relative; padding-top:20px; display:inline-block; } .notify-badge{ position: absolute; right:-20px; top:10px; background:red; text-align: center; border-radius: 30px 30px 30px 30px; color:white; padding:5px 10px; font-size:20px; } <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css” rel=”stylesheet”/> <div class=”col-sm-4″> <div class=”item”> <a href=”#”> <span class=”notify-badge”>NEW</span> <img src=”https://picsum.photos/200″ alt=”” /> </a> </div> </div> … Read more

Change Notification with Sql Server 2008

Notification Services was deprecated, but you don’t want to use that anyway. You might consider Service Broker messages in some scenarios; the details depend on your app. In most cases, you can probably use SqlDependency or SqlCacheDependency. The way they work is that you include a SqlDependency object with your query when you issue it. … Read more

Event OnClick for a button in a custom notification

I am writing code in my MyActivity.java class that extends android.app.Activity It creates a custom notification, when user click on the button it sends a broadcast. There is a broadcast receiver that receives the broadcast. private void createDownloadNotification() { Intent closeButton = new Intent(“Download_Cancelled”); closeButton.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0, closeButton, 0); RemoteViews … Read more

java.lang.SecurityException: Requires VIBRATE permission on Jelly Bean 4.2

I got the same Exception in Jelly Bean 4.1.2, then following changes I made to resolve this 1.added permission in manifest file. <uses-permission android:name=”android.permission.VIBRATE”></uses-permission> 2.Notification Composing covered by Try-Catch try { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this) .setSmallIcon(R.drawable.ic_notif_alert) .setContentTitle(getResources().getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) .setContentText(msg) .setStyle(bigTextStyle) .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); mBuilder.setAutoCancel(true); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); Log.d(TAG, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)