How to create chooser in activity starter

When i start an activity it is showing available apps for activity and asking to set default (just once, always). I dont want to let it ask for setting default. user should select an app every time user starts activity.

Is there any way to get available package names and classes to start a corresponding activity,
so i can show in my own user interface (UI)

U can add buttons or options for this
Like u have an option to choose either whatsapp or whatsapp business for further movement then u can use a dialogue or show some buttons to select one of them and then set the values of your activity starters according to respective selection.
I think u asks for something like this :relieved:

Na… Actually he is asking to get the particular app package name which he choose from the list… .

He never which one client going to choose… So he want that particular app package which was choosed by the client…

1 Like

@ziach5451
@Alapjeet_Singh_RK is correct
I want to accept payments via upi app
when i start activity it is asking to select app and 2 options are are visible (just once, always)
if user clicks “always” it will be set as default upi app
It will be a drawback to my app because user cant select different upi app everytime

I am referring this page


Code

val uri = Uri.parse("upi://pay").buildUpon()
        .appendQueryParameter("pa", upiId)
        .appendQueryParameter("pn", name)
        .appendQueryParameter("tn", note)
        .appendQueryParameter("am", amount)
        .appendQueryParameter("cu", "INR")
        .build()


val upiPayIntent = Intent(Intent.ACTION_VIEW)
upiPayIntent.data = uri

// will always show a dialog to user to choose an app
val chooser = Intent.createChooser(upiPayIntent, "Pay with")

// check if intent resolves
if (null != chooser.resolveActivity(packageManager)) {
    startActivityForResult(chooser, UPI_PAYMENT)
} else {
    Toast.makeText([email protected], "No UPI app found, please install one to continue", Toast.LENGTH_SHORT).show()
}
  1. I want to know how to apply this in activity starter:
    val chooser = Intent.createChooser(upiPayIntent, “Pay with”)
    (OR)
  2. Is there a way to get available package-names and package-classes for the corresponding activity and user can select upi app and start activity

Even I am trying that… @sonumohammad333
One method is working but there a risk…

What is that method? @Alapjeet_Singh_RK