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
@Zia_Choudhary @Alapjeet 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(this@UPIActivity, "No UPI app found, please install one to continue", Toast.LENGTH_SHORT).show()
}
I want to know how to apply this in activity starter:
val chooser = Intent.createChooser(upiPayIntent, “Pay with”)
(OR)
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