Android PrintService display toast

55 Views Asked by At

I have an android PrintService launched by an Application. I would like to be able to display toasts from the PrintService when I'm selecting the printer on which to print etc. (UI generated by the android system, picture here).

On Android <11 it works fine, however for 11+, I'm not able to display a toast... I've tried several code (Kotlin) :

Toast.makeText(<context>, message, Toast.LENGTH_LONG).show()
Handler(Looper.getMainLooper()).post {
    Toast.makeText(context.applicationContext, message, Toast.LENGTH_LONG).show()
}

Where I tried the following values of :

  • this (the PrintService)
  • this.applicationContext
  • this.baseContext

Still, I'm never able to display a toast on the printer selection page... Is it possible ? What is wrong in my code ?

0

There are 0 best solutions below