Android Studio Baidu Map Development (10) Voice broadcast problem: normal navigation, but unable to voice broadcast

Source: Internet
Author: User

I. Preface

The first time to do the navigation, and did not pay attention to voice broadcast, today specifically to improve this feature. But found that the implementation of voice broadcast also encountered some problems, in the official discussion area also found that the problem of voice broadcast is particularly numerous, the problem is basically: can navigate normally, but can not voice broadcast. So I have some of their own understanding and solutions to record, hoping to help other problematic friends.

Two. What you need to do 1. Configuration issues

In addition to the map display, positioning, navigation needs of the configuration, TTS broadcast need to add a whitelist, click to go. As shown below:

Here are some key places to watch out for:

    • App Package Name: This is basically fine.
    • Application Signature: This signature is not the SHA1 to apply for AK, but the MD5 that is packaged into the APK, there are two ways to get MD5:
      (1) The first kind: The APK file format is modified to. rar, that is, the compressed package, then unzip, under the Meta-inf folder will have a Cert.rsa file, and then the command window into Meta-inf, enter Keytool-printcert-file CERT. RSA

      (2) The second type: a self-named. jks file is generated when you package it, and the packaging process can be viewed, most notably this JKs file. Then in the command window into the directory of this jks file, enter keytool-list-v-keystore self-naming. JKs, so you can see MD5.

    • AK: This is the AK you applied for before, this is fine.

2. Related code

These two parts are in the official demo.
1. Internal TTS broadcast status callback handler

    PrivateHandler Ttshandler =NewHandler () { Public void Handlemessage(Message msg) {intType = Msg.what;Switch(type) {//tts Broadcast begins                 CaseBaiduNaviManager.TTSPlayMsgType.PLAY_START_MSG: {//showtoastmsg ("Handler:tts play Start");                     Break; }//tts the end of the broadcast                 CaseBaiduNaviManager.TTSPlayMsgType.PLAY_END_MSG: {//showtoastmsg ("Handler:tts play End");                     Break; }default: Break; }        }    };

2. Service Authorization and initialization

Private void Initnavi() {baidunavimanager.getinstance (). Init ( This, Msdcardpath, App_folder_name,NewBaidunavimanager.naviinitlistener () {@Override             Public void Onauthresult(intStatus, String msg) {string authinfo;if(0= = status) {Authinfo ="Key check succeeded!"; }Else{authinfo ="Key checksum failed,"+ msg; } driverouteactivity. This. Runonuithread (NewRunnable () {@Override                     Public void Run() {}}); } Public void initsuccess() {initsetting (); } Public void Initstart() {} Public void initfailed() {}}, Ttshandler,///Previously defined TTS broadcast backhaul handler             NULL); }

3. Go to Navigation

BaiduNaviManager    .getInstance()        .launchNavigator(            DriveRouteActivity.this,    //建议是应用的主Activity            list,                           //传入的算路节点,顺序是起点、途经点、终点,其中途经点最多三个            2,                              //算路偏好 1:推荐 8:少收费 2:高速优先 4:少走高速 16:躲避拥堵            true,                           //true表示真实GPS导航,false表示模拟导航,据我所知,新的SDK中,模拟导航不支持语音播报            new DemoRoutePlanListener(sPNode)//开始导航回调监听器,在该监听器里一般是进入导航过程页面            );
Three. Why can I navigate but not voice broadcast

In theory, the function of voice broadcasting can be done by configuring the work and the three parts of the code above. But often in the details of the error, will lead to the journey navigation but can not voice broadcast, the following are some of my understanding and solutions, for reference only, we can from these aspects to troubleshoot errors.
(1) TTS whitelist signature from the APK, so in the development phase should be unable to voice broadcast, because the development phase of the signature and the packaging of the signature is inconsistent; at least my personal problem is this, the development stage is not voice broadcast, the APK installed on the phone can be normal voice broadcast;
(2) using a newer SDK, analog navigation does not support voice broadcast;

Android Studio Baidu Map Development (10) Voice broadcast problem: normal navigation, but unable to voice broadcast

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.