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
When you create the Non Activity class in your Activity, pass the context to its constructor:
NonActivityClass nonActivityClass = new NonActivityClass(this);
Non Activity constructor:
Context mContext;
public NonActivityClass(Context context){
mContext = context;
}
then use:
new AlertDialog.Builder(mContext)...
in the Non Activity class