I am trying to Call method from Another Activity but it is not calling. When i use intent it works but when i call method it fails. The method which is in onNotificationPosted()
. Here is the code
public class NotificationListener extends NotificationListenerService {
Context context;
private DatabaseReference dbref;
private FirebaseAuth mAuth;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
dbref= FirebaseDatabase.getInstance().getReference();
mAuth=FirebaseAuth.getInstance();
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
ChatActivity ch=new ChatActivity();
ch.location();
// Intent n=new Intent(NotificationListener.this,ChatActivity.class);
//startActivity(n);
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
Log.i("Msg","Notification Removed");
}
}
The intent which is commented works but the method is not calling. Please help me. Thanks in advance.