Here is my code
fun Uri.getOriginalFileName(context: Context): String? {
return context.contentResolver.query(this, null, null, null, null)?.use {
val nameColumnIndex = it.getColumnIndex(OpenableColumns.DISPLAY_NAME)
it.moveToFirst()
it.getString(nameColumnIndex)
}
}
@Composable
fun AppNotice() {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.type = "*/*"; ///
intent.addCategory(Intent.CATEGORY_OPENABLE);
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {
activityResult -> if (activityResult.resultCode == RESULT_OK)
{
Log.d("appDebug", "oky")
var uri = intent.getData()
val name: String? = uri?.getOriginalFileName(Context)
Log.d("seeFile", "$name")
}
else {
Log.d("appDebug", "Denied")
}
Button(onClick={launcher.launch(intent)})
{Text("Button")}
}
Context is a class then how to know what method will i need in this line/context name: String? = uri?.getOriginalFileName(Context)
I went to adroid.dev page but found a huge page and cant figure out what i need since saw only few uri permission related stuffs.