Android get Google Play Store app version

前端 未结 8 1648
渐次进展
渐次进展 2021-02-06 11:49

I am using this code to get the Google Play Store app version but this is causing my app to hang. Please specify another way to get the app version or how I can use this code to

8条回答
  •  名媛妹妹
    2021-02-06 12:21

    Change this two lines

    {
     newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + "package name" + "&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")
    ....
    

    you are using BuildConfig.APPLICATION_ID but you need package_name

    BuildConfig is provided by Gradle. If you are not building using Gradle then you cannot access the package name using BuildConfig.

    I would use Context.getPackageName() because the result is provided from the operating system, rather than a constant in build parameters.

提交回复
热议问题