跳转至

应用信息获取

AppUtils 用来获取和App有关的相关信息。

AppUtils

@Composable
fun AppInfo() {
    val appInfo = mapOf(
        "getPackageName" to AppUtils.getPackageName(),
        "getAppName" to AppUtils.getAppName(),
        "getVersionName" to AppUtils.getVersionName(),
        "getVersionCode" to AppUtils.getVersionCode().toString(),
        "getAppDebug" to AppUtils.getAppDebug().toString()
    ).toList()

    Column {
        Text(
            text = "Function name: getAppBitmap",
            modifier = Modifier.padding(15.dp)
        )

        Image(
            bitmap = AppUtils.getAppBitmap().asImageBitmap(),
            contentDescription = null,
            modifier = Modifier.padding(15.dp)
        )

        LazyColumn(modifier = Modifier.fillMaxSize()) {
            items(appInfo) { item ->
                ListItem(
                    headlineText = {
                        Text(text = "Function name: ${item.first}")
                    },
                    supportingText = {
                        Text(text = item.second)
                    }
                )
            }
        }
    }
}

查看示例代码