사용 Jsoup 라이브러리를 따르 다음 단계 :
앱 수준 build.gradle에 의존성을 1.add
compile 'org.jsoup:jsoup:1.10.2'
2.이 클래스를 sr에 추가하십시오. c
public class VersionChecker extends AsyncTask<String, String, String> {
private String newVersion;
@Override
protected String doInBackground(String... params) {
try {
newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID + "&hl=en")
.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();
} catch (IOException e) {
e.printStackTrace();
}
return newVersion;
}}// add following lines to your code where you want to get live app version
VersionChecker versionChecker = new VersionChecker();try {
mLatestVersionName = versionChecker.execute().get();} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();}
당신은 자신의 서버와 상점 버전이 있어야 함을 의미합니다. 앱을 실행하면 앱이 내 서버의 현재 버전과 버전을 비교합니다. – Hoa
예. 그것을 시도하십시오;) –
고맙습니다 :)하지만 구글 플레이에서 애플 리케이션 버전을 얻을 수있는 방법은 무엇입니까? – Hoa