简体   繁体   中英

Cannot call FileProvider's getUriForFile in Kotlin

I am encountered a strange behavior in Kotlin when creating a custom File provider like this

import android.support.v4.content.FileProvider
class MyFileProvider: FileProvider()

I cannot make this call MyFileProvider.getUriForFile(... Android studio cannot resolve the reference fro getUriForFile

But with java it works

import android.support.v4.content.FileProvider;

public class MyFileProvider extends FileProvider {
}

Am I missing something?

getUriForFile() is static
Kotlin doesn't inherit static methods, as there's no such thing as static in Kotlin, and you can't really inherit them.
But you can simply use FileProvider.getUriForFile()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM