Android – SendBroadcast issue inside onCLickllistener

androidbroadcastclicklistener

btn2=(Button) rowView.findViewById(R.id.button1);
    btn2.setText("Find");

      btn2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
                    Intent Message1=new Intent();
                Message1.setAction("map");
                sendBroadcast(Message1);}

The error says the method of broadcast is undefined inside the oclicklistener. why is that?

Best Answer

Should be context.sendBroadcast(Intent). You can do CurrentActivity.this.sendBroadcast(Intent) Inside of OnClickListener there is no context instance that's why it cannot execute method of Context

Related Topic