I have an activity that uses:
val i = Intent(Intent.ACTION_MAIN)
i.addCategory(Intent.CATEGORY_HOME)
startActivity(i)
Toast.makeText(this, "Fetching attendance, hold your phone close to the terminal ...",
Toast.LENGTH_SHORT).show()
To automatically return to the home screen once the function above is called, but the toast does not show up. How can I make a toast show up while on the home screen?
The this
stands for the context. So instead of using this
use applicationContext
Toast.makeText(applicationContext, "Fetching attendance, hold your phone close to the terminal ...",
Toast.LENGTH_SHORT).show()