根据包名获取第三方应用的版本号信息:
fun getAppInFo(pkg:String):String{
val versionName = this.packageManager.getPackageInfo(pkg, 0).versionName
var versionCode :Long = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
this.packageManager.getPackageInfo(pkg, 0).longVersionCode
}else{
this.packageManager.getPackageInfo(pkg, 0).versionCode.toLong()
}
return "versionCode = $versionCode"
}