I am trying to start up notification in background service which is also Location Listener. I have a function:
public Notification CreateNotification(){ Intent notificationIntentStop = new Intent(this.getApplicationContext(), StopService.class); PendingIntent contentIntentStop = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntentStop, 0); Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.logo); Shortcuts shorts = new Shortcuts(this); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.logo) .setContentTitle("Localarm Running") .setLargeIcon(largeIcon); mBuilder.addAction(R.drawable.ico, "Stop", contentIntentStop); mBuilder.setContentText("Awake Me Up running."); mBuilder.setPriority(Notification.PRIORITY_MAX); Notification bui = mBuilder.build(); bui.flags|= Notification.FLAG_NO_CLEAR; Intent notificationIntent = new Intent(this.getApplicationContext(), Intro.class); PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntent, 0); bui.contentIntent = contentIntent; return bui; } And in onStart I call:
createNotification.notify();
However I get the following error:
"object not locked by thread before notify()"
how do I fix this? It literally needs to be called once and just keep running.