我有一个类,我要么在创建时知道一个特定的值,要么我需要生成它,这有点贵.我可以仅在实际需要时生成值吗?
val expensiveProperty: A
constructor(expensiveProperty: A) {
this.expensiveProperty = expensiveProperty
}
constructor(value: B) {
// this doesn't work
this.expensiveProperty = lazy { calculateExpensiveProperty(value) }
}
Run Code Online (Sandbox Code Playgroud) 我有一个连接到Bitmessage网络的应用程序,即一直从P2P网络下载和处理数据.此外,它应该(可选)仅使用WiFi /未计量网络.
我已经通过使用JobScheduler实现了这一点,但不幸的是它超时了10分钟(在Lollipop上显然甚至是1分钟).
简而言之,我该如何实现一项服务呢