我有以下代码:
ExecutorService executor = Executors.newSingleThreadExecutor()
Future<String> future = executor.submit(new Callable<String>() {
@Override
String call() throws Exception {
stream.filter(fq)
return null
}
})
try {
future.get(4, TimeUnit.MINUTES)
}
一旦4分钟结束,我想执行另一种方法。我会把这段代码放在哪里?
答案 0 :(得分:1)
抓住try {
future.get(4, TimeUnit.MINUTES)
} catch(TimeoutException e) {
//call your method code here, it will be called only if the operation times out
myMethod();
}
并将您的代码放入catch块。
Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
Caused by: java.lang.IllegalAccessError: tried to access method android.support.v4.content.ContextCompat.<init>:(Ljava/lang/String;)V from class com.google.firebase.iid.zzg