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
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.