So I am trying to access a method in another activity, basically to check if there's new data in the chat and if there is, it shows a toast. But I'm getting an error whenever I try to use this, or Activity.this in any function. If I try to use context, it works but rest all functions start giving null.
Here's what I did
DoTheTask.class
Chat c = new Chat();
c.Mymethod("true",id);
Chat.class
public void Mymethod(String fd, String id)
{
if(fd.equals("true")){
Toast.makeText(this,"Chat is open", Toast.LENGTH_LONG).show();
}
}
Here the "this" inside toast is giving NPE, I passed context with the method but I want to use this because I have many other functions required which work only with this or activity.this and not context (they give errors)