新版本可用时如何更新现有应用

时间:2019-06-14 07:10:59

标签: android updates

第二次从应用程序访问商店时,更新按钮在游戏商店中显示,这是我的尝试。

//getting the version from j soup library

try {
        newVersion = Jsoup.connect(AppConstant.APP_PLAYSTORE_URL+ "&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.hAyfc:nth-child(4) > span:nth-child(2) > div:nth-child(1) > span:nth-child(1)")
                .first()
                .ownText();
    } catch (IOException e) {
        e.printStackTrace();
    }



 //compare version name
 if (mLatestVersionName != null && !mLatestVersionName.equals("") &&(Double.parseDouble(BuildConfig.VERSION_NAME) !=Double.parseDouble(mLatestVersionName))) {
            openCheckerDialog();
        } 




  //getting callback status from play store either it is updated or not
 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == RC_UPDATE_APP_FROM_PLAYSTORE && resultCode == Activity.RESULT_OK)
    {
     //doing task
        Log.v("Update", "Not Updated");
    }
    else
        openCheckerDialog();
}




 //moving to play store from the app 
    Intent i = new Intent(Intent.ACTION_VIEW);
                        i.setData(Uri.parse(APP_PLAYSTORE_URL));
                        startActivityForResult(i, RC_UPDATE_APP_FROM_PLAYSTORE);

但这不能按预期工作,有人可以帮忙吗?欢迎任何建议和代码审查

2 个答案:

答案 0 :(得分:0)

正式提供-强制应用更新的新方式

  • 此功能正式称为“应用内更新”

  • 应用内更新仅适用于运行Android 5.0(API级别)的设备 21)或更高版本

  • 要求您使用Play Core库1.5.0或更高版本。

  

有两种类型的选项可用于强制进行应用内更新:

  • 灵活-允许用户放弃更新并继续 使用应用程序
  • 立即-将显示一个阻止用户界面,该界面将 提示用户进行更新。

注意:应用内更新API查看Google Play中的生产,Alpha和Beta 曲目。您不能依靠此API将旧的生产版本更新为内部测试更新

链接:

文档- http://docs.xlwings.org/en/stable/converters.html#pandas-dataframe-converter

播放核心库- https://developer.android.com/guide/app-bundle/in-app-updates

涵盖了用例/场景的参考文章- https://developer.android.com/guide/app-bundle/playcore#include_playcore

  

注意:当您将应用发布为Android应用捆绑包时,使用应用内更新的应用允许的最大压缩下载大小为   150MB。应用内更新与使用APK的应用不兼容   扩展文件(.obbfiles)。

(4个赞)

答案 1 :(得分:0)

这可能对您有帮助

import os
import time
import csv
from tqdm import tqdm
import pandas as pd
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import ElementNotVisibleException
from selenium.common.exceptions import ElementClickInterceptedException

working_directory = r"xx"
os.chdir(working_directory)
options = webdriver.ChromeOptions() 

prefs = {
        "download.default_directory": r"xx",
       "download.prompt_for_download": False,
       "download.directory_upgrade": True}

options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(r"C:xxx\chromedriver.exe", options = options) 

driver.get("website")

# Login
driver.find_element_by_class_name("smallLoginBox").click()
driver.implicitly_wait(1)
time.sleep(2) 
driver.find_element_by_id('loginFormUC_loginEmailTextBox').send_keys('EMAIL')
driver.find_element_by_id('loginFormUC_loginPasswordTextBox').send_keys('PASWORD')
driver.find_element_by_xpath("//input[@value='Logg inn']").click()

# Get a custom list of firms
bedrifter  = []

with open("./listwithIDs.csv") as csvDataFile:
    csvReader = csv.reader(csvDataFile)
    for row in csvReader:
        bedrifter.append(row[0])

# THE LOOP

for ID in tqdm(bedrifter_gjenstår):
    driver.get("website" + ID)
    source = driver.page_source

    if not "Ingen data" in source: # make sure there is an excel file. If not, loop continues to next ID.
        # first click on button "download excel"
        try:
            driver.find_element_by_id("exportExcel").click()
        except ElementNotVisibleException:
            WebDriverWait(driver, 120).until(
                    EC.presence_of_element_located((By.ID, "exportExcel")))
            driver.find_element_by_id("exportExcel").click()
        except ElementClickInterceptedException:
            WebDriverWait(driver, 120).until(
                    EC.presence_of_element_located((By.ID, "exportExcel")))
            driver.find_element_by_id("exportExcel").click()

        # second click, choosing what format the excel file should be in
        try:
            driver.find_element_by_id("mainContentPlaceHolder_mainContentPlaceHolder_mainContentPlaceHolder_AccountingNumberTableUc_excelLinkButton").click()
        except ElementNotVisibleException:
            WebDriverWait(driver, 120).until(
                    EC.presence_of_element_located((By.ID, "mainContentPlaceHolder_mainContentPlaceHolder_mainContentPlaceHolder_AccountingNumberTableUc_excelLinkButton")))
            driver.find_element_by_id("mainContentPlaceHolder_mainContentPlaceHolder_mainContentPlaceHolder_AccountingNumberTableUc_excelLinkButton").click()

# code to switch between windows to remove download window and continue the code
        try: 
            window_export = driver.window_handles[1]
        except IndexError:
            time.sleep(3)
            print("sleep")
            window_export = driver.window_handles[1]

        try:
            window_main = driver.window_handles[0]
        except IndexError:
            time.sleep(3)
            print("sleep")
            window_main = driver.window_handles[0]

        driver.switch_to.window(window_export)
        driver.close()
        driver.switch_to.window(window_main)

相关问题