I have tried many solutions now. However, I cannot get the compiler to approve setResult(int, intent) in my activity. I have started the activity with startActivityForResult.
Can you see the problem?
My code looks like this:
networkServiceMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//TODO: Implement the methods that should be executed on validation results
PrinterData printerData = intent.getParcelableExtra(NetworkService.VALIDATE_PRINTER_RESULT);
if(printerData != null)
{
Intent data = new Intent();
data.putExtra(VALIDATE_PRINTER_RESULT, printerData);
setResult(RESULT_OK, data);
finish();
}
else
{
}
}
};
Android Studio gives this error:

BroadcastReceiver has its setResult method, which takes three parameters, not two, and you probably want to use setResult from the class Activity. Reference it like:
ActivityName.this.setResult(RESULT_OK, data);
if the BroadcastReceiver is declared inside an Activity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With