我有同样的问题问在这里。我想应用接受的答案。但是我无法做到这一点,因为IDE在这一行中指出了这一点:
Thread.currentThread().wait();
“等待”是一个未解决的参考。我在Android Studio中使用kotlin,所以也许kotlin插件会导致此问题。在“偏好设置”的“插件”部分中,我安装了1.0.6-release-Studio2.2-1 kotlin版本。而在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
}
如果我将kotlin_version更改为1.0.6-release-Studio2.2-1,则指向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)
。
因此,我的第一个问题是如何处理未解决的参考错误。第二个:还有其他/更好的方法来强制IntentService等待,直到DownloadManager完成下载并按此问题的要求调用onReceive()。
请参阅页面中间的https://kotlinlang.org/docs/reference/java-interop.html:
有效的Java项目69谨建议使用并发实用程序,而不是wait()和notify()。因此,这些方法在类型为Any的引用上不可用。如果您确实需要致电给他们,可以将其转换为
java.lang.Object
:(foo as java.lang.Object).wait()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句