Alert Dialog in non activity class

前端 未结 4 2177
南旧
南旧 2021-01-26 02:37

I have a code which checks some data and shows an alert in a non activity class. But while running application program crashed and does not showing alert dialog. I used below

4条回答
  •  故里飘歌
    2021-01-26 03:29

    My guess is that your context is null...

    Can't you send down a context, to the "codes which checks some data" before starting to checking the data, instead of trying to fetch a context that doesn't exists?

    Else make a activity that makes the alertdialog instead, and then startup that activity from your "service" class.

提交回复
热议问题