特别是我想检查的 versionName 和 versionCode。一个为空,另一个为0。包名是正确的。我验证了,有什么想法吗?
final PackageManager pm = getPackageManager();
final String packageName = getPackageName();
if (getMyApp().getURL() == URLS.PROD && getMyApp().IS_CHECK_VERSION == 1) {
try {
new Thread() {
public void run() {
HttpURLConnection conn = null;
String responseString = null;
try {
String versionName = "1.0";
try {
PackageInfo pi = pm.getPackageInfo(packageName, 0);
versionName = pi.versionName;
} catch (NameNotFoundException e) {
e.printStackTrace();
}