I am building an app using kotlin in android studio which is mainly used to scan the QR code. Once the QR code is scanned successfully then clicking on proceed to pay button on my app will open the clover sales app . After the transaction is completed in the sales app . I want to close the clover sales app(programmatically) and return to my app.
I am able to open the clover sales app using intend(the code is attached below). But, I am quite stuck to close the clover sales app(programmatically) and return to my app .
So, Could anyone please guide me how to achieve that? Does anyone have any idea of how can I be sure to go back to application A when application B is over ?
' private fun openCloverSalesApp(amountInCents: Long) {
val packageManager: PackageManager = packageManager
val intent = packageManager.getLaunchIntentForPackage(CLOVER_SALES_PACKAGE)
if (intent != null) {
try {
intent.putExtra("CustomerId", customerId.toString())
intent.putExtra(Intents.EXTRA_AMOUNT, amountInCents)
// Launch the Clover Sales app
startActivity(intent)
} else {
// Show an error message if the Clover Sales app is not installed
Log.e("CloverSales", "Clover Sales app not found")
}
}'