Hi i want to show messageBox or notification when connection lost in Static DB class but i cant use getApplicationContext() becouse its a static class and i tried to call other class called notification but i have error so how i could pass activity object to my new class .
A:
You cannot have a "static DB class" that works with the UI in the fashion you are seeking. For any call that may fail, have an Activity
(or possibly other Context
) be passed in as a parameter to the method.
CommonsWare
2010-03-26 19:07:39
A:
You can also pass the activity context in the constructor of your class. Code would help though.
Bostjan
2010-03-26 19:32:41
+1
A:
How are you doing it's wrong. You should pass a context each time when you call your static methods.
However you can have a static Context property in that class, and you could put in your current context before calling for a method. But this is bad practice! Don't do it!
Pentium10
2010-03-26 19:50:01