1
我正在面對從PlayStore獲取我的應用的最新版本代碼的問題。我有應用程序apk以及穿上apk上載的Playstore。現在,當我打電話Play商店中獲取最新版本的移動應用程序,如果提供響應爲:在多個apks的情況下以編程方式從playstore獲取最新應用的版本代碼
它根據設備
因此而改變,有沒有辦法來獲取最新版本移動應用的代碼?
下面是我用來檢索應用程序的最新版本代碼的代碼。
private class GetVersionCode extends AsyncTask<Void, String, String> {
@Override
protected String doInBackground(Void... voids) {
String newVersion = null;
try {
newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + getApplicationContext().getPackageName() + "&hl=it").timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6").referrer("http://www.google.com")
.get()
.select("div[itemprop=softwareVersion]")
.first()
.ownText();
return newVersion;
} catch (Exception e) {
return null;
}
}
@Override
protected void onPostExecute(String onlineVersion) {
super.onPostExecute(onlineVersion);
if (onlineVersion != null && !onlineVersion.isEmpty()) {
String currentVer = getIntVersionNumber(currentVersion);
String onlineVer = getIntVersionNumber(onlineVersion);
if (Integer.parseInt(currentVer) < Integer.parseInt(onlineVer)) {
showAlertDialog(onlineVersion);
}
}
}
}
什麼是不同的版本實際的錯誤? 你不從JSOUP方法或其他東西上面獲取版本號嗎? –
您的案例中不同的版本代碼是預期的行爲,因爲您有多個apks,即移動版和磨損版。 –
@BhupatBheda我沒有從jsoup獲得任何版本代碼,而是它給我的字符串作爲可用的各種版本。 – DPP