我 div Integer (ex 3/6) 的 div 以及如何在 kotlin 中将其变成 0.500000。我尝试了一些解决方案,但没有一个解决我的问题。
val num = BigDecimal(3.div(6))
println("%.6f".format(num))
Run Code Online (Sandbox Code Playgroud)
但结果是 0.000000
我需要从本地存储中选择一个 pdf 并将其转换为 byteArray 作为 firebase 数据库路径。我搜索了很多,但没有找到这个问题的答案。
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if(requestCode == RC_SELECT_PDF && resultCode == Activity.RESULT_OK &&
data != null && data.data != null) {
val hereUrl:Uri = data.data
var os = ByteArrayOutputStream()
var inputStream = this@RegistrasiPengajarActivity?.contentResolver.openInputStream(hereUrl)
var byteArray = inputStream.available()
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我能做的,我已经选择了 pdf,但仍然不知道如何转换它
我正在使用 firestore,当我从 firestore 获取时间戳时卡住了。我如何Timestamp(seconds=1556006384, nanoseconds=994000000)在 kotlin 中将其转换为 Date。
我的最小 SDK 是 21,所以下面的代码不起作用
val timestamp = it["time"] as com.google.firebase.Timestamp
val milliseconds = timestamp.seconds * 1000 + timestamp.nanoseconds / 1000000
val tz = ZoneId.of("Asia/Jakarta (UTC+07:00)")
val localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(milliseconds), tz)
Run Code Online (Sandbox Code Playgroud)
谢谢你。
我不知道我的应用程序发生了什么。我认为我build.gradle的应用程序有问题:
这是错误:
发现多个文件与操作系统独立路径“META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version”
和我的 build.gradle app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "id.alif.ngajiasik"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//firebase
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.4' …Run Code Online (Sandbox Code Playgroud)