I used this code and it can only get the version of other app above Android 11 and earlier. On Android 12 it doesn't work.
String uri = "com.uptodown.installer";
android.content.pm.PackageManager pm = getPackageManager(); try { android.content.pm.PackageInfo pInfo = pm.getPackageInfo(uri, android.content.pm.PackageManager.GET_ACTIVITIES); String version = pInfo.versionName;textview.setText(version); } catch (android.content.pm.PackageManager.NameNotFoundException e) { }
I tried to try but it only works on Android 11 or earlier.
From what I can tell, getPackageInfo()
is deprecated as you've used it. From the ide:
Deprecated
Use getPackageInfo(String, PackageManager.PackageInfoFlags) instead.
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.