The problem is this, passing in intent two values ​​for one key:

val allowIntent = Intent(this, PaymentIntentService::class.java) allowIntent.putExtra("button", true) val serviceAllowIntent = PendingIntent.getService(this, 1, allowIntent, 0) val cancelIntent = Intent(this, PaymentIntentService::class.java) cancelIntent.putExtra("button", false) val serviceCancelIntent = PendingIntent.getService(this, 0, cancelIntent, 0) 

After that, the place where I get these values, I try to call the getSessionData() method, but alas, it does not reach it, because for some reason getBooleanExtra () does not work quite correctly, but does not find the value by the button key:

 if (intent.extras != null) { if (intent.extras.containsKey("button") && intent.extras.containsKey("sessionSecret")) { allow = intent.getBooleanExtra("button", true) getSessionData() } } else cancelNotification() 

Perhaps because I check first intent.extras and then I work with getBooleanExtra () I don’t know, but I don’t see any alternatives to get the values ​​I need by the key.

  • Perhaps, and if you immediately check intent.hasExtra("button") && intent.hasExtra("sessionSecret") , without touching extras ? - woesss
  • Interesting. Can we create explicit intents with the same key, but with different values, and then meet these values ​​in one place according to this key? Or I misunderstand something, enlighten pzhl. - TimurVI
  • How do you transmit and receive intents? - rjhdby
  • @TimurVI Well, something from the heading, well, I’m interested in two values, so it actually fits perfectly. - Morozov
  • Use the normal value for the flag with the last parameter when creating PendingIntent . For example, PendingIntent.getService(this, 1, allowIntent, PendingIntent.FLAG_UPDATE_CURRENT); - eugeneek

0