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.