I would like to start an activity with an image every time HostApduService receives any Apdu command.
override fun processCommandApdu(commandApdu: ByteArray?, extras: Bundle?): ByteArray {
val intent = Intent(this, ImageActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.setAction(Intent.ACTION_VIEW)
startActivity(intent)
return hexStringToByteArray("...")
}
This solution works well if my application is currently in the foreground. Otherwise (app is in background or not launched) even though apdu command is processed correctly, the activity doesn't show on the screen.
According to doc ( link ) activity should be shown.
How to start an activity this way without additional permissions? Apps like GooglePay seem to work that way.
I am not interested in solution including android.permission.SYSTEM_ALERT_WINDOW permission. I know it is possible to show view using WindowManager with WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY. Unfortunately this solution requires explicit user permission - redirecting user to change value in device display settings.