小编zha*_*hen的帖子

华为 Android AppUpdateClient - 如何测试

我正在我的应用程序中集成华为服务以便在AppGallery中发布。我已经集成了AppUpdateClient https://developer.huawei.com/consumer/en/doc/development/HMS-References/appupdateclient

我已经在 AppGallery 的“开放测试”中发布了我的应用程序。我使用较低版本的代码在发布模式下构建 apk,并将其安装在我的智能手机上。

val client: AppUpdateClient = JosApps.getAppUpdateClient(activity)
client.checkAppUpdate(activity, object : CheckUpdateCallBack {
    override fun onUpdateInfo(intent: Intent?) {
        val status = intent?.getIntExtra(UpdateKey.STATUS, -1)
        ...
Run Code Online (Sandbox Code Playgroud)

返回的状态始终为3。华为文档:3:常量值NO_UPGRADE_INFO,表示没有更新信息。

如果我打开 AppGallery,它会通知我该应用程序有更新,如果我单击“更新”,它会成功更新该应用程序。

如何从我的应用程序测试该过程?

android kotlin huawei-mobile-services appgallery-connect

7
推荐指数
1
解决办法
995
查看次数

检测应用程序是否从华为应用市场安装

我想检测应用程序的安装源。

在Android上我们可以使用两种方法来检测安装源:PackageManager#getInstallerPackageName(String)PackageManager#getInstallSourceInfo(String)。这两个调用都将返回安装程序应用程序的包名称。例如:

  • 亚马逊应用商店:com.amazon.venezia
  • 谷歌播放:com.android.vending

我的问题是,对于从华为应用市场安装的应用程序,此方法会返回什么?

android android-package-managers huawei-mobile-services appgallery huawei-developers

6
推荐指数
1
解决办法
1012
查看次数

使用多风味编译GMS和HMS包。但是GMS版本编译的时候报错

我有一个应用程序配置了两种编译风格,一种使用 HMS,另一种则不使用。不使用HMS的flavor编译时,包名与json文件中的包名不一致。结果,出现错误。

Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processAppgalleryconnectLatestDebugAGCPlugin'.
> ERROR: Failed to verify AGConnect-Config '/client/package_name', expected: 'com.dise.appge.hms', but was: 'com.dise.appge.gms'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
Run Code Online (Sandbox Code Playgroud)

那么不同风味使用不同包名时如何解决这个问题呢?

android json package firebase huawei-mobile-services

6
推荐指数
1
解决办法
8404
查看次数

华为地图无法加载图块

我已遵循此处此处的文档(非常简单),但地图视图不会加载任何图块。

我使用HMS Toolkit,配置向导成功。我还设置了我的 api 密钥,在我的应用程序类和活动类 onCreate 中都使用了这一行。

MapsInitializer.setApiKey(HUAWEI_API_KEY);

以下是设备信息和SDK版本:

  • 手机型号:华为 Y7 Prime 2018
  • EMUI版本:8.0.0
  • HMS核心版本:6.1.0.305
  • 地图SDK版本:com.huawei.hms:maps:6.0.0.301

这是屏幕:

在此输入图像描述

相关错误日志:

E/HmsMapKit_MapView_151:createDelegate:创建者== null

E/HmsMapKit_GrsClient_24:GRS 返回空。

E/HmsMapKit_ErrorTraceLogPusher_4:缓存错误跟踪日志:ErrorTraceLogDTO{ scene = GET_GRS_URL_FAILED', message='GRS 返回空,服务名称为 com.huawei.hms.map。'}

E/HmsMapKit_ErrorTraceLogPusher_12:eventId 为 null 或为空。

E/HmsMapKit_AuthenticateClient_27:com.huawei.hms.maps.foundation.client.c发生异常

E/HmsMapKit_ErrorTraceLogPusher_4:缓存错误跟踪日志:ErrorTraceLogDTO{场景= ACCESS_SERVICE_ERROR',消息='060001:NETWORK_ERROR'}

E/HmsMapKit_AuthenticateCache_0:认证错误,抛出RetryException。

E/HmsMapKit_CopyrightDelegate_27:获取版权声明html数据失败:htmlData = null

E/HmsMapKit_TileCache_38:startUrlRequest身份失败,没有权限获取图块。授权结果:060011

PS:我在这个演示中遇到了完全相同的问题。

android android-studio huawei-mobile-services huawei-developers huawei-map-kit

6
推荐指数
1
解决办法
1373
查看次数

缺少必需参数:client_id

我尝试从 hms 服务器请求 oauth 令牌,但它总是返回missing required parameter: client_id给我。

url: https://oauth-login.cloud.huawei.com/oauth2/v3/token?grant_type=client_credentials&client_id=XXX&client_secret=XXX

header: Content-Type application/x-www-form-urlencoded

response: 
{
    "sub_error": 20001,
    "error_description": "missing required parameter: client_id",
    "error": 1102
}
Run Code Online (Sandbox Code Playgroud)

oauth-2.0 huawei-mobile-services huawei-account

6
推荐指数
1
解决办法
2万
查看次数

函数int()向负无穷大(floor)舍入或为零?

我看到为什么-1/2在C++中被评估为0,而在Python中为-1?表示整数除法在Python中向无穷大舍入,即floor应用于结果.

在我练习的时候,我想int(value)也会做一些事情floor,这些事情int(-1.5) == -1应该-2在我的脑海里.

所以问题是:为什么规则integer division和功能之间是不一致的int()?有没有合理的解释?

python int floor

5
推荐指数
1
解决办法
1535
查看次数

正则表达式在两个标签之间找到单词

如何在python中使用正则表达式来查找标签之间的单词?

s = """<person>John</person>went to<location>London</location>"""
......
.......
print 'person of name:' John
print 'location:' London 
Run Code Online (Sandbox Code Playgroud)

python regex

5
推荐指数
2
解决办法
1万
查看次数

如何在Python中减去多维数组?

我有这个多维数组:

n = [[1], [2], [3], [4], [5], [6], [7, 10], [8], [9], [7, 10]]
Run Code Online (Sandbox Code Playgroud)

我想用1来减去所有这些.所以结果将是:

result = [[0], [1], [2], [3], [4], [5], [6, 9], [7], [8], [6, 9]]
Run Code Online (Sandbox Code Playgroud)

python multidimensional-array

5
推荐指数
1
解决办法
101
查看次数

华为短信检索器 api 无法正常工作且华为设备

我正在尝试在华为设备中检索 OTP。但它不起作用。

我已经在华为开发者控制台中创建了满足所有要求的应用程序。

下面是我用来检索短信的代码。

private fun initSmsManager() {

        val task = ReadSmsManager.start(this@MainActivity)

        task.addOnCompleteListener {

            if (task.isSuccessful) {
                // The service is enabled successfully. Continue with the process.
                Toast.makeText(this, "ReadSms service has been enabled.", Toast.LENGTH_LONG).show()
            } else
                Toast.makeText(this, "The service failed to be enabled.", Toast.LENGTH_LONG).show()
        }
        task.addOnSuccessListener(this, OnSuccessListener {
                if(task.isSuccessful){
                    Toast.makeText(this, "ReadSms service has been enabled.", Toast.LENGTH_LONG).show()
                    myReceiver = MyBroadcastReceiver();
                    val intentFilter = IntentFilter(READ_SMS_BROADCAST_ACTION)
                    registerReceiver(myReceiver, intentFilter)
                }
        })
        task.addOnFailureListener(this, OnFailureListener {
            Toast.makeText(this,it.message,Toast.LENGTH_SHORT).show();
        })
    }
Run Code Online (Sandbox Code Playgroud)

广播接收器

class MyBroadcastReceiver : BroadcastReceiver() {

    companion …
Run Code Online (Sandbox Code Playgroud)

sms-retriever-api huawei-mobile-services huawei-account huawei-developers

5
推荐指数
1
解决办法
1286
查看次数

Android Studio:无法解析配置“:classpath”的所有工件

我在Android Studio中创建了一个新项目,弹出错误:

A problem occurred configuring root project 'About Me'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0-release-764.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-764/kotlin-gradle-plugin-1.5.0-release-764.pom
       - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-764/kotlin-gradle-plugin-1.5.0-release-764.pom
     Required by:
         project :

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

android gradle kotlin

5
推荐指数
1
解决办法
3万
查看次数