Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

【华为游戏多媒体】调用获取Token接口得到的Token值是null

 Share


Recommended Posts

问题描述

新版本的华为游戏多媒体SDK可以传入参数cpAccessToken进行SDK的初始化操作,当前我们没有搭建服务器,直接在Android客户端调用了获取Token的接口,结果获取到的Token值是null。
0260086000056735644.20220707092507.22968

参考文档:

  • 获取Token
  • SDK初始化

问题分析

运行代码没有报任何错误,调用接口也没有打印任何错误日志,只有用断点调试的方式来查看到底是哪行代码发生了异常。调试发现是下面这行代码发生了

NetworkOnMainThreadException异常,直接跳转到了catch代码段,意思是在主线程访问了网络。

0260086000056735644.20220707092521.61483

0260086000056735644.20220707092530.95115
在Android中网络访问必须放在子线程,如果在主线程出现访问网络的操作,就会发生此异常。

问题解决

把接口放在子线程来调用,成功获取到Token的值。(如何在子线程调用接口以及子线程与主线程如何通信,属于Android基础知识,此处就不再赘述。)
0260086000056735644.20220707092549.60164
如果上述方法不能解决您的问题,您可以通过提单的方式获取华为的技术支持。

Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...