I am trying to get the text typed on the direct reply. I can get the text but when click the send text button, it opens the activity that intent shows.
val resultIntent = Intent(this, MessagesActivity::class.java)
val stackBuilder = TaskStackBuilder.create(this)
stackBuilder.addNextIntent(resultIntent)
val resultPendingIntent = PendingIntent.getActivity(
this,
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
)
And here's Notification Builder
val mBuilder = Notification.Builder(this, id)
.setContentTitle(data["title"])
.setContentText(data["body"])
.setLargeIcon(image)
.addAction(action)
.setSmallIcon(R.drawable.logo)
.setAutoCancel(true)
I don't want it to open the activity. Also I tried to use a intent service, it does not work.
You are using
PendingIntent.getActivity
which means you want to handle result from your operation on activity. It's logical that this activity need to start before proceeding. From documentation ofgetActivity
:You need to use
PendingIntent.getBroadcast
.For more information look here