<lambda>null1 package com.android.sharetest
2 
3 import android.app.Activity
4 import android.app.AlertDialog
5 import android.content.Intent
6 import android.os.Bundle
7 import android.os.ResultReceiver
8 
9 class RefinementActivity : Activity() {
10     override fun onCreate(savedInstanceState: Bundle?) {
11         super.onCreate(savedInstanceState)
12         val resultReceiver =
13             intent.getParcelableExtra(Intent.EXTRA_RESULT_RECEIVER, ResultReceiver::class.java)
14         val sharedIntent = intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)
15         val builder: AlertDialog.Builder = AlertDialog.Builder(this)
16         builder
17                 .setMessage(
18                     """
19                     |Is modified by payload selection: ${!intent.isInitial}
20                     |
21                     |Complete the share?
22                     """.trimMargin()
23                 )
24                 .setTitle("Refinement invoked!")
25                 .setPositiveButton("Yes") { _, _ ->
26                     val bundle = Bundle().apply {
27                         putParcelable(Intent.EXTRA_INTENT, sharedIntent)
28                     }
29                     resultReceiver?.send(RESULT_OK, bundle)
30                     finish()
31                 }
32                 .setNegativeButton("No") { _, _ ->
33                     resultReceiver?.send(RESULT_CANCELED, null)
34                     finish()
35                 }
36                 .setOnCancelListener {
37                     resultReceiver?.send(RESULT_CANCELED, null)
38                     finish()
39                 }
40 
41         builder.create().show()
42     }
43 }
44