3

I have the same question as asked here. I wanted to apply the accepted answer. But I was unable to do that, because IDE stated that in the line:

 Thread.currentThread().wait();

"wait" was an unresolved reference. I use kotlin in Android Studio so maybe kotlin plugin causes the problem. In plugins section of Preferences stated that I have 1.0.6-release-Studio2.2-1 kotlin version installed. Whereas in the project build.gradle:

buildscript {
ext.kotlin_version = '1.0.6'
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "io.realm:realm-gradle-plugin:2.3.0"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

If I change kotlin_version to be 1.0.6-release-Studio2.2-1 Ide points that Kotlin version that is used for building with Gradle (1.0.6-release-Studio2.2-1) differs from the one bundled into the IDE plugin (1.0.6).

So my first question is how to deal with the unresolved reference error. And the second: is there other/better way to force IntentService to wait until DownloadManager finishes its download and calls onReceive() as asked in this question.

Community
  • 1
  • 1
AlexKost
  • 2,792
  • 4
  • 22
  • 42

1 Answers1

7

Please see https://kotlinlang.org/docs/reference/java-interop.html, somewhere in the middle of the page:

Effective Java Item 69 kindly suggests to prefer concurrency utilities to wait() and notify(). Thus, these methods are not available on references of type Any. If you really need to call them, you can cast to java.lang.Object: (foo as java.lang.Object).wait()

aha
  • 3,702
  • 3
  • 38
  • 47