在移动互联飞速发展的今天!O2O的崛起,许多应用都离不开可导航功能!经过几天的学习,今天把所学所想些一下。以供分享:
高德地图的基本配置请看我的第一篇博客,百度地图之定位
1.首先下载高德提供的SDK
- AMapNavi_1.9.4_20161201.jar 导航SDK
- AMap_Search_V3.2.1_20160308.jar
- Msc.jar 讯飞语音合成jar包
2.语音合成工具代码:
注意在使用讯飞语音时,需要申请key:
package com.pansoft.oilgas.gaodenavigation;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import com.amap.api.navi.AMapNaviListener;
import com.amap.api.navi.model.AMapLaneInfo;
import com.amap.api.navi.model.AMapNaviCross;
import com.amap.api.navi.model.AMapNaviInfo;
import com.amap.api.navi.model.AMapNaviLocation;
import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo;
import com.amap.api.navi.model.AimLessModeCongestionInfo;
import com.amap.api.navi.model.AimLessModeStat;
import com.amap.api.navi.model.NaviInfo;
import com.autonavi.tbt.TrafficFacilityInfo;
import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechError;
import com.iflytek.cloud.SpeechSynthesizer;
import com.iflytek.cloud.SynthesizerListener;
/**
* 语音播报组件
*/
public class TTSController implements SynthesizerListener, AMapNaviListener {
public static final String TAG = TTSController.class.getSimpleName();
public static TTSController ttsManager;
boolean isfinish = true;
private Context mContext;
// 合成对象.
private SpeechSynthesizer mSpeechSynthesizer;
@Override
public void onEvent(int i, int i1, int i2, Bundle bundle) {
}
TTSController(Context context) {
mContext = context;
}
public static TTSController getInstance(Context context) {
if (ttsManager == null) {
ttsManager = new TTSController(context);
}
return ttsManager;
}
public void init() {
// 初始化合成对象.
// “appid=” + “586f93a2”,讯飞语音的key:
SpeechUser.getUser().login(mContext, null,