Why does IDE swear?

val intent = Intent() //Expecting an element intent.action = packageName.plus(".granted") intent.putExtra(Constants.GRANT_NAME, Manifest.permission.CAMERA) sendBroadcast(intent)//Unexpected tokens (use ';' to separate expressions on the same line) 

Why in this case there are such errors? What's wrong?

ps And it works

 LocalBroadcastManager.getInstance(this) .sendBroadcast(Intent(packageName.plus(".granted")) .putExtra(Constants.GRANT_NAME, Manifest.permission.CAMERA)) 
  • one
    Because the sendBroadcast method you call this in the first case. - Eugene Krivenja
  • I have a gap pattern :) In Java it works, but not in the cottage. - DuosDuo
  • More practice and everything will work out;) - Eugene Krivenja

1 answer 1

Replace last line with

 LocalBroadcastManager.getInstance(this).sendBroadcast(intent) 

and everything should work.