findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(!title.getText().toString().isEmpty() && !message.getText().toString().isEmpty())
{
Toast.makeText(MainActivity.this, message.getText().toString(), Toast.LENGTH_SHORT).show();
FcmNotificationsSender notificationsSender=new FcmNotificationsSender( "/topics/all",title.getText().toString(),message.getText().toString()
,(Activity)getApplicationContext(),MainActivity.this);
notificationsSender.SendNotifications(); } else { Toast.makeText(MainActivity.this, "Please Enter Details", Toast.LENGTH_SHORT).show(); }
}
});
CodePudding user response:
Change those MainActivity.this
to view.getContext()
.
CodePudding user response:
(Activity)getApplicationContext() this line is the issue. Just remove (Activity) casting on app context.