Android determines if an activity context or application context is valid

I have an async task that does a download and shows a progress dialog. I would like to be able to not show the dialog if it is called by the service and therefore cannot display the dialog. The problem is the way to determine what type of context I have (activity or application)?

+4
source share
1 answer
if( context instanceof Activity ) { //... } else { //... } 
+11
source

All Articles