我有一个活动使用:
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()
当上面的函数被调用,但是toast没有出现时,自动返回主屏幕。如何在主屏幕上显示祝酒词?
this
代表上下文。所以用applicationContext
this
Toast.makeText(applicationContext, "Fetching attendance, hold your phone close to the terminal ...",
Toast.LENGTH_SHORT).show()