├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── back_btn_image.png │ │ │ │ ├── map_traffic_white.png │ │ │ │ ├── map_traffic_hl_white.png │ │ │ │ ├── prefer_setting_btn_off.png │ │ │ │ ├── prefer_setting_btn_on.png │ │ │ │ ├── route_car_result_prefer_icon_normal.png │ │ │ │ ├── route_car_result_prefer_icon_selected.png │ │ │ │ └── button_background_white.xml │ │ │ ├── drawable │ │ │ │ ├── map_sticker_verydanger_hl.png │ │ │ │ └── route_car_result_prefer_icon.xml │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── colors.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── activity_basic_navi.xml │ │ │ │ ├── adapter_strategy_choose.xml │ │ │ │ ├── activity_strategy_choose.xml │ │ │ │ └── activity_calculate_route.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── amap │ │ │ │ └── multiroute │ │ │ │ ├── Bean │ │ │ │ ├── StrategyStateBean.java │ │ │ │ └── StrategyBean.java │ │ │ │ ├── StrategyChooseActivity.java │ │ │ │ ├── adapter │ │ │ │ └── StrategyChooseAdapter.java │ │ │ │ ├── RouteNaviActivity.java │ │ │ │ ├── util │ │ │ │ └── Utils.java │ │ │ │ └── CalculateRouteActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── amap │ │ │ └── multiroute │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── amap │ │ └── multiroute │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── resource ├── app-debug.apk ├── download.png ├── navi_snapshot.png ├── route_snapshot.png └── strategy_snapshot.png ├── .idea ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /resource/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/resource/app-debug.apk -------------------------------------------------------------------------------- /resource/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/resource/download.png -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /resource/navi_snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/resource/navi_snapshot.png -------------------------------------------------------------------------------- /resource/route_snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/resource/route_snapshot.png -------------------------------------------------------------------------------- /resource/strategy_snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/resource/strategy_snapshot.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/back_btn_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable-xhdpi/back_btn_image.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/map_traffic_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable-xhdpi/map_traffic_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/map_sticker_verydanger_hl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable/map_sticker_verydanger_hl.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/map_traffic_hl_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable-xhdpi/map_traffic_hl_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/prefer_setting_btn_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable-xhdpi/prefer_setting_btn_off.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/prefer_setting_btn_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable-xhdpi/prefer_setting_btn_on.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/route_car_result_prefer_icon_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable-xhdpi/route_car_result_prefer_icon_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/route_car_result_prefer_icon_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-multiroute-display/HEAD/app/src/main/res/drawable-xhdpi/route_car_result_prefer_icon_selected.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jul 12 11:56:38 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AndroidNaviMultirouteDisplay 3 | 58eedde4 4 | 避免拥堵 5 | 避免收费 6 | 不走高速 7 | 高速优先 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/button_background_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/route_car_result_prefer_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/amap/multiroute/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/amap/multiroute/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 48dp 6 | 5dp 7 | 18sp 8 | 30dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #307EFE 7 | #737373 8 | #535353 9 | #f6f6f6 10 | #ebebeb 11 | #ffffff 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_basic_navi.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/ligen/develope/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/multiroute/Bean/StrategyStateBean.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute.Bean; 2 | 3 | /** 4 | * Created by ligen on 16/10/31. 5 | */ 6 | public class StrategyStateBean { 7 | private int mStrategyCode; 8 | private boolean mOpen; 9 | 10 | public StrategyStateBean(int strategyCode, boolean open) { 11 | setStrategyCode(strategyCode); 12 | setOpen(open); 13 | } 14 | 15 | public int getStrategyCode() { 16 | return mStrategyCode; 17 | } 18 | 19 | public void setStrategyCode(int mStrategyCode) { 20 | this.mStrategyCode = mStrategyCode; 21 | } 22 | 23 | public boolean isOpen() { 24 | return mOpen; 25 | } 26 | 27 | public void setOpen(boolean mOpen) { 28 | this.mOpen = mOpen; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | android.useDeprecatedNdk=true -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | } 6 | apply plugin: 'com.android.application' 7 | 8 | android { 9 | compileSdkVersion 23 10 | buildToolsVersion '25.0.0' 11 | 12 | defaultConfig { 13 | applicationId "com.amap.multiroute" 14 | minSdkVersion 14 15 | targetSdkVersion 26 16 | versionCode 1 17 | versionName "1.0" 18 | ndk { 19 | abiFilters 'armeabi-v7a' 20 | } 21 | } 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | sourceSets { 29 | main { 30 | jniLibs.srcDirs = ['libs'] 31 | } 32 | } 33 | } 34 | 35 | dependencies { 36 | compile fileTree(dir: 'libs', include: '*.jar') 37 | testCompile 'junit:junit:4.12' 38 | compile 'com.android.support:appcompat-v7:23.2.1' 39 | compile 'com.amap.api:navi-3dmap:latest.integration' 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/adapter_strategy_choose.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/multiroute/Bean/StrategyBean.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute.Bean; 2 | 3 | /** 4 | * Created by ligen on 16/11/2. 5 | */ 6 | public class StrategyBean { 7 | private boolean mCongestion; 8 | private boolean mCost; 9 | private boolean mHightspeed; 10 | private boolean mAvoidhightspeed; 11 | 12 | public StrategyBean(boolean congestion,boolean cost,boolean highspeed,boolean avoidhighspeed){ 13 | setCongestion(congestion); 14 | setCost(cost); 15 | setHightspeed(highspeed); 16 | setAvoidhightspeed(avoidhighspeed); 17 | } 18 | 19 | public boolean isCongestion() { 20 | return mCongestion; 21 | } 22 | 23 | public void setCongestion(boolean mCongestion) { 24 | this.mCongestion = mCongestion; 25 | } 26 | 27 | public boolean isCost() { 28 | return mCost; 29 | } 30 | 31 | public void setCost(boolean mCost) { 32 | this.mCost = mCost; 33 | } 34 | 35 | public boolean isHightspeed() { 36 | return mHightspeed; 37 | } 38 | 39 | public void setHightspeed(boolean mHightspeed) { 40 | this.mHightspeed = mHightspeed; 41 | } 42 | 43 | public boolean isAvoidhightspeed() { 44 | return mAvoidhightspeed; 45 | } 46 | 47 | public void setAvoidhightspeed(boolean mAvoidhightspeed) { 48 | this.mAvoidhightspeed = mAvoidhightspeed; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 44 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_strategy_choose.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 27 | 28 | 34 | 35 | 36 | 37 | 46 | 47 | 48 | 54 | 55 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-navi-multiroute-display 2 | 多路径规划、导航示例 3 | ## 前述 ## 4 | - [高德官网申请Key](http://lbs.amap.com/dev/#/). 5 | - 阅读[参考手册](http://a.amap.com/lbs/static/unzip/Android_Map_Doc/index.html). 6 | - [科大讯飞开放平台申请Appid](http://www.xfyun.cn/services/online_tts). 7 | - 工程基于Android 导航 SDK、科大讯飞在线语音合成SDK实现 8 | 9 | 10 | ## 扫一扫安装## 11 | ![Screenshot]( https://github.com/amap-demo/android-navi-multiroute-display/raw/master/resource/download.png ) 12 | 13 | 14 | ##多路径规划、导航示例 15 | ## 使用方法## 16 | ###1:配置搭建AndroidSDK工程### 17 | - [Android Studio工程搭建方法](http://lbs.amap.com/api/android-sdk/guide/creat-project/android-studio-creat-project/#add-jars). 18 | - [通过maven库引入SDK方法](http://lbsbbs.amap.com/forum.php?mod=viewthread&tid=18786). 19 | 20 | 21 | ###2:运行示例配置项### 22 | - AndroidManifest.xml 配置高德开放平台key 23 | ```java 24 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ``` 45 | - string.xml 配置科大讯飞Appid 46 | ```java 47 | 科大讯飞Appid 48 | ``` 49 | - CalculateRouteActivity 设置导航起终点 50 | ```java 51 | private NaviLatLng endLatlng; //导航终点 52 | private NaviLatLng startLatlng; //导航起点 53 | ``` 54 | - CalculateRouteActivity 选择模拟\真实导航 55 | ```java 56 | /** 57 | * 开始导航 58 | */ 59 | private void startNavi() { 60 | Intent gpsintent = new Intent(getApplicationContext(), RouteNaviActivity.class); 61 | gpsintent.putExtra("gps", false); // gps 为true为真实导航,为false为模拟导航 62 | startActivity(gpsintent); 63 | } 64 | ``` 65 | 66 | ##效果展示## 67 | ####多路径规划 68 | ![Screenshot]( https://github.com/amap-demo/android-navi-multiroute-display/raw/master/resource/route_snapshot.png ) 69 | 70 | ####驾车偏好设置 71 | ![Screenshot]( https://github.com/amap-demo/android-navi-multiroute-display/raw/master/resource/strategy_snapshot.png ) 72 | 73 | ####导航 74 | ![Screenshot]( https://github.com/amap-demo/android-navi-multiroute-display/raw/master/resource/navi_snapshot.png ) 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/multiroute/StrategyChooseActivity.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.KeyEvent; 7 | import android.view.View; 8 | import android.widget.LinearLayout; 9 | import android.widget.ListView; 10 | 11 | import com.amap.multiroute.Bean.StrategyStateBean; 12 | import com.amap.multiroute.adapter.StrategyChooseAdapter; 13 | import com.amap.multiroute.util.Utils; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * 驾车偏好设置 20 | */ 21 | public class StrategyChooseActivity extends Activity implements View.OnClickListener { 22 | private boolean congestion, cost, hightspeed, avoidhightspeed; 23 | List mStrategys = new ArrayList(); 24 | private ListView mStrategyChooseListView; 25 | private StrategyChooseAdapter mStrategyAdapter; 26 | private LinearLayout mBackLayout; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | getActivityIntent(); 32 | mStrategys.add(new StrategyStateBean(Utils.AVOID_CONGESTION, congestion)); 33 | mStrategys.add(new StrategyStateBean(Utils.AVOID_COST, cost)); 34 | mStrategys.add(new StrategyStateBean(Utils.AVOID_HIGHSPEED, avoidhightspeed)); 35 | mStrategys.add(new StrategyStateBean(Utils.PRIORITY_HIGHSPEED, hightspeed)); 36 | setContentView(R.layout.activity_strategy_choose); 37 | mStrategyAdapter = new StrategyChooseAdapter(this.getApplicationContext(), mStrategys); 38 | mStrategyChooseListView = (ListView) findViewById(R.id.strategy_choose_list); 39 | mStrategyChooseListView.setAdapter(mStrategyAdapter); 40 | mBackLayout = (LinearLayout) findViewById(R.id.title_lly_back); 41 | mBackLayout.setOnClickListener(this); 42 | } 43 | 44 | @Override 45 | protected void onPause() { 46 | super.onPause(); 47 | } 48 | 49 | @Override 50 | public boolean onKeyDown(int keyCode, KeyEvent event) { 51 | if (keyCode == KeyEvent.KEYCODE_BACK) { 52 | setResultIntent(); 53 | } 54 | return super.onKeyDown(keyCode, event); 55 | } 56 | 57 | private void setResultIntent(){ 58 | Intent intent = new Intent(); 59 | for (StrategyStateBean bean : mStrategys) { 60 | if (bean.getStrategyCode() == Utils.AVOID_CONGESTION) { 61 | intent.putExtra(Utils.INTENT_NAME_AVOID_CONGESTION, bean.isOpen()); 62 | } 63 | 64 | if (bean.getStrategyCode() == Utils.AVOID_COST) { 65 | intent.putExtra(Utils.INTENT_NAME_AVOID_COST, bean.isOpen()); 66 | } 67 | 68 | if (bean.getStrategyCode() == Utils.AVOID_HIGHSPEED) { 69 | intent.putExtra(Utils.INTENT_NAME_AVOID_HIGHSPEED, bean.isOpen()); 70 | } 71 | 72 | if (bean.getStrategyCode() == Utils.PRIORITY_HIGHSPEED) { 73 | intent.putExtra(Utils.INTENT_NAME_PRIORITY_HIGHSPEED, bean.isOpen()); 74 | } 75 | } 76 | this.setResult(Utils.ACTIVITY_RESULT_CODE, intent); 77 | } 78 | 79 | private void getActivityIntent() { 80 | Intent intent = this.getIntent(); 81 | if (intent == null) { 82 | return; 83 | } 84 | congestion = intent.getBooleanExtra(Utils.INTENT_NAME_AVOID_CONGESTION, false); 85 | cost = intent.getBooleanExtra(Utils.INTENT_NAME_AVOID_COST, false); 86 | avoidhightspeed = intent.getBooleanExtra(Utils.INTENT_NAME_AVOID_HIGHSPEED, false); 87 | hightspeed = intent.getBooleanExtra(Utils.INTENT_NAME_PRIORITY_HIGHSPEED, false); 88 | } 89 | 90 | @Override 91 | public void onClick(View view) { 92 | if(view.getId() == R.id.title_lly_back){ 93 | setResultIntent(); 94 | this.finish(); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/multiroute/adapter/StrategyChooseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.amap.multiroute.Bean.StrategyStateBean; 12 | import com.amap.multiroute.R; 13 | import com.amap.multiroute.util.Utils; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * 驾车偏好设置adapter,高速优先与不走高速、避免收费互斥 19 | * Created by ligen on 16/10/28. 20 | */ 21 | public class StrategyChooseAdapter extends BaseAdapter implements View.OnClickListener { 22 | 23 | private Context mContext; 24 | private List mStrategys; 25 | 26 | public StrategyChooseAdapter(Context context, List strategys) { 27 | mContext = context; 28 | mStrategys = strategys; 29 | } 30 | 31 | @Override 32 | public int getCount() { 33 | return mStrategys.size(); 34 | } 35 | 36 | @Override 37 | public StrategyStateBean getItem(int i) { 38 | return mStrategys.get(i); 39 | } 40 | 41 | @Override 42 | public long getItemId(int i) { 43 | return i; 44 | } 45 | 46 | @Override 47 | public View getView(int i, View view, ViewGroup viewGroup) { 48 | Holder holder; 49 | if (view == null) { 50 | holder = new Holder(); 51 | view = LayoutInflater.from(mContext).inflate(R.layout.adapter_strategy_choose, null); 52 | holder.mStrategyNameText = (TextView) view.findViewById(R.id.strategy_name); 53 | holder.mStrategyChooseFlagImage = (ImageView) view.findViewById(R.id.strategy_choose_flag); 54 | holder.mStrategyBean = mStrategys.get(i); 55 | view.setTag(holder); 56 | } else { 57 | holder = (Holder) view.getTag(); 58 | } 59 | view.setOnClickListener(this); 60 | StrategyStateBean strategyBean = mStrategys.get(i); 61 | if (strategyBean != null) { 62 | int strategyCode = strategyBean.getStrategyCode(); 63 | String strategyName = getStrategyName(strategyCode); 64 | holder.mStrategyNameText.setText(strategyName); 65 | 66 | } 67 | if (holder != null && holder.mStrategyBean != null) { 68 | boolean isOpen = holder.mStrategyBean.isOpen(); 69 | if (isOpen) { 70 | holder.mStrategyChooseFlagImage.setBackgroundResource(R.drawable.prefer_setting_btn_on); 71 | } else { 72 | holder.mStrategyChooseFlagImage.setBackgroundResource(R.drawable.prefer_setting_btn_off); 73 | } 74 | } 75 | 76 | return view; 77 | } 78 | 79 | private String getStrategyName(int strategyCode) { 80 | String strategyName = ""; 81 | switch (strategyCode) { 82 | case Utils.AVOID_CONGESTION: 83 | strategyName = mContext.getString(R.string.congestion); 84 | break; 85 | case Utils.AVOID_COST: 86 | strategyName = mContext.getString(R.string.cost); 87 | break; 88 | case Utils.AVOID_HIGHSPEED: 89 | strategyName = mContext.getString(R.string.avoidhightspeed); 90 | break; 91 | case Utils.PRIORITY_HIGHSPEED: 92 | strategyName = mContext.getString(R.string.hightspeed); 93 | break; 94 | default: 95 | break; 96 | } 97 | return strategyName; 98 | } 99 | 100 | @Override 101 | public void onClick(View view) { 102 | Holder holder = (Holder) view.getTag(); 103 | if (holder == null || holder.mStrategyBean == null) { 104 | return; 105 | } 106 | if (holder.mStrategyBean.isOpen()) { 107 | holder.mStrategyBean.setOpen(false); 108 | } else { 109 | holder.mStrategyBean.setOpen(true); 110 | } 111 | 112 | int strategyCode = holder.mStrategyBean.getStrategyCode(); 113 | 114 | if (strategyCode == Utils.PRIORITY_HIGHSPEED) { 115 | for (StrategyStateBean bean : mStrategys) { 116 | if (bean.getStrategyCode() == Utils.AVOID_COST || bean.getStrategyCode() == Utils.AVOID_HIGHSPEED) { 117 | bean.setOpen(false); 118 | } 119 | } 120 | } 121 | 122 | if (strategyCode == Utils.AVOID_COST || strategyCode == Utils.AVOID_HIGHSPEED) { 123 | for (StrategyStateBean bean : mStrategys) { 124 | if (bean.getStrategyCode() == Utils.PRIORITY_HIGHSPEED) { 125 | bean.setOpen(false); 126 | } 127 | } 128 | } 129 | notifyDataSetChanged(); 130 | } 131 | 132 | public class Holder { 133 | public TextView mStrategyNameText; 134 | public ImageView mStrategyChooseFlagImage; 135 | public StrategyStateBean mStrategyBean; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/multiroute/RouteNaviActivity.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.Window; 6 | import android.widget.Toast; 7 | 8 | import com.amap.api.navi.AMapNavi; 9 | import com.amap.api.navi.AMapNaviListener; 10 | import com.amap.api.navi.AMapNaviView; 11 | import com.amap.api.navi.AMapNaviViewListener; 12 | import com.amap.api.navi.model.AMapLaneInfo; 13 | import com.amap.api.navi.model.AMapModelCross; 14 | import com.amap.api.navi.model.AMapNaviCameraInfo; 15 | import com.amap.api.navi.model.AMapNaviCross; 16 | import com.amap.api.navi.model.AMapNaviInfo; 17 | import com.amap.api.navi.model.AMapNaviLocation; 18 | import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo; 19 | import com.amap.api.navi.model.AMapServiceAreaInfo; 20 | import com.amap.api.navi.model.AimLessModeCongestionInfo; 21 | import com.amap.api.navi.model.AimLessModeStat; 22 | import com.amap.api.navi.model.NaviInfo; 23 | import com.autonavi.tbt.TrafficFacilityInfo; 24 | 25 | /** 26 | * 按照选定策略导航 27 | */ 28 | public class RouteNaviActivity extends Activity implements AMapNaviListener, AMapNaviViewListener { 29 | 30 | AMapNaviView mAMapNaviView; 31 | AMapNavi mAMapNavi; 32 | 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | requestWindowFeature(Window.FEATURE_NO_TITLE); 38 | setContentView(R.layout.activity_basic_navi); 39 | 40 | 41 | mAMapNaviView = (AMapNaviView) findViewById(R.id.navi_view); 42 | mAMapNaviView.onCreate(savedInstanceState); 43 | mAMapNaviView.setAMapNaviViewListener(this); 44 | 45 | mAMapNavi = AMapNavi.getInstance(getApplicationContext()); 46 | mAMapNavi.addAMapNaviListener(this); 47 | mAMapNavi.setUseInnerVoice(true); 48 | 49 | mAMapNavi.setEmulatorNaviSpeed(60); 50 | boolean gps=getIntent().getBooleanExtra("gps", false); 51 | if(gps){ 52 | mAMapNavi.startNavi(AMapNavi.GPSNaviMode); 53 | }else{ 54 | mAMapNavi.startNavi(AMapNavi.EmulatorNaviMode); 55 | } 56 | 57 | 58 | } 59 | 60 | @Override 61 | protected void onResume() { 62 | super.onResume(); 63 | mAMapNaviView.onResume(); 64 | } 65 | 66 | @Override 67 | protected void onPause() { 68 | super.onPause(); 69 | mAMapNaviView.onPause(); 70 | 71 | // 72 | // 停止导航之后,会触及底层stop,然后就不会再有回调了,但是讯飞当前还是没有说完的半句话还是会说完 73 | // mAMapNavi.stopNavi(); 74 | } 75 | 76 | @Override 77 | protected void onDestroy() { 78 | super.onDestroy(); 79 | mAMapNaviView.onDestroy(); 80 | mAMapNavi.stopNavi(); 81 | // mAMapNavi.destroy(); 82 | 83 | } 84 | 85 | @Override 86 | public void onInitNaviFailure() { 87 | Toast.makeText(this, "init navi Failed", Toast.LENGTH_SHORT).show(); 88 | } 89 | 90 | @Override 91 | public void onInitNaviSuccess() { 92 | } 93 | 94 | @Override 95 | public void onStartNavi(int type) { 96 | 97 | } 98 | 99 | @Override 100 | public void onTrafficStatusUpdate() { 101 | 102 | } 103 | 104 | @Override 105 | public void onLocationChange(AMapNaviLocation location) { 106 | 107 | } 108 | 109 | @Override 110 | public void onGetNavigationText(int type, String text) { 111 | 112 | } 113 | 114 | @Override 115 | public void onGetNavigationText(String s) { 116 | 117 | } 118 | 119 | @Override 120 | public void onEndEmulatorNavi() { 121 | } 122 | 123 | @Override 124 | public void onArriveDestination() { 125 | } 126 | 127 | @Override 128 | public void onCalculateRouteFailure(int errorInfo) { 129 | } 130 | 131 | @Override 132 | public void onReCalculateRouteForYaw() { 133 | 134 | } 135 | 136 | @Override 137 | public void onReCalculateRouteForTrafficJam() { 138 | 139 | } 140 | 141 | @Override 142 | public void onArrivedWayPoint(int wayID) { 143 | 144 | } 145 | 146 | @Override 147 | public void onGpsOpenStatus(boolean enabled) { 148 | } 149 | 150 | @Override 151 | public void onNaviSetting() { 152 | } 153 | 154 | @Override 155 | public void onNaviMapMode(int isLock) { 156 | 157 | } 158 | 159 | @Override 160 | public void onNaviCancel() { 161 | finish(); 162 | } 163 | 164 | @Override 165 | public void onNaviTurnClick() { 166 | 167 | } 168 | 169 | @Override 170 | public void onNextRoadClick() { 171 | 172 | } 173 | 174 | @Override 175 | public void onScanViewButtonClick() { 176 | } 177 | 178 | @Deprecated 179 | @Override 180 | public void onNaviInfoUpdated(AMapNaviInfo naviInfo) { 181 | } 182 | 183 | @Override 184 | public void updateCameraInfo(AMapNaviCameraInfo[] aMapNaviCameraInfos) { 185 | 186 | } 187 | 188 | @Override 189 | public void updateIntervalCameraInfo(AMapNaviCameraInfo aMapNaviCameraInfo, AMapNaviCameraInfo aMapNaviCameraInfo1, int i) { 190 | 191 | } 192 | 193 | @Override 194 | public void onServiceAreaUpdate(AMapServiceAreaInfo[] aMapServiceAreaInfos) { 195 | 196 | } 197 | 198 | @Override 199 | public void onNaviInfoUpdate(NaviInfo naviinfo) { 200 | } 201 | 202 | @Override 203 | public void OnUpdateTrafficFacility(TrafficFacilityInfo trafficFacilityInfo) { 204 | 205 | } 206 | 207 | @Override 208 | public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo) { 209 | 210 | } 211 | 212 | @Override 213 | public void showCross(AMapNaviCross aMapNaviCross) { 214 | } 215 | 216 | @Override 217 | public void hideCross() { 218 | } 219 | 220 | @Override 221 | public void showModeCross(AMapModelCross aMapModelCross) { 222 | 223 | } 224 | 225 | @Override 226 | public void hideModeCross() { 227 | 228 | } 229 | 230 | @Override 231 | public void showLaneInfo(AMapLaneInfo[] laneInfos, byte[] laneBackgroundInfo, byte[] laneRecommendedInfo) { 232 | 233 | } 234 | 235 | @Override 236 | public void showLaneInfo(AMapLaneInfo aMapLaneInfo) { 237 | 238 | } 239 | 240 | @Override 241 | public void hideLaneInfo() { 242 | 243 | } 244 | 245 | @Override 246 | public void onCalculateRouteSuccess(int[] ints) { 247 | 248 | } 249 | 250 | @Override 251 | public void notifyParallelRoad(int i) { 252 | 253 | } 254 | 255 | @Override 256 | public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos) { 257 | 258 | } 259 | 260 | @Override 261 | public void updateAimlessModeStatistics(AimLessModeStat aimLessModeStat) { 262 | 263 | } 264 | 265 | @Override 266 | public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo aimLessModeCongestionInfo) { 267 | 268 | } 269 | 270 | @Override 271 | public void onPlayRing(int i) { 272 | 273 | } 274 | 275 | @Override 276 | public void onLockMap(boolean isLock) { 277 | } 278 | 279 | @Override 280 | public void onNaviViewLoaded() { 281 | } 282 | 283 | @Override 284 | public boolean onNaviBackClick() { 285 | return false; 286 | } 287 | 288 | } 289 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/multiroute/util/Utils.java: -------------------------------------------------------------------------------- 1 | package com.amap.multiroute.util; 2 | 3 | import android.text.Html; 4 | import android.text.Spanned; 5 | 6 | import com.amap.api.navi.model.AMapNaviPath; 7 | import com.amap.api.navi.model.AMapNaviStep; 8 | import com.amap.multiroute.Bean.StrategyBean; 9 | 10 | import java.text.DecimalFormat; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | 14 | public class Utils { 15 | private static DecimalFormat fnum = new DecimalFormat("##0.0"); 16 | public static final int AVOID_CONGESTION = 4; // 躲避拥堵 17 | public static final int AVOID_COST = 5; // 避免收费 18 | public static final int AVOID_HIGHSPEED = 6; //不走高速 19 | public static final int PRIORITY_HIGHSPEED = 7; //高速优先 20 | 21 | public static final int START_ACTIVITY_REQUEST_CODE = 1; 22 | public static final int ACTIVITY_RESULT_CODE = 2; 23 | 24 | public static final String INTENT_NAME_AVOID_CONGESTION = "AVOID_CONGESTION"; 25 | public static final String INTENT_NAME_AVOID_COST = "AVOID_COST"; 26 | public static final String INTENT_NAME_AVOID_HIGHSPEED = "AVOID_HIGHSPEED"; 27 | public static final String INTENT_NAME_PRIORITY_HIGHSPEED = "PRIORITY_HIGHSPEED"; 28 | 29 | 30 | public static String getFriendlyTime(int s) { 31 | String timeDes = ""; 32 | int h = s / 3600; 33 | if (h > 0) { 34 | timeDes += h + "小时"; 35 | } 36 | int min = (int) (s % 3600) / 60; 37 | if (min > 0) { 38 | timeDes += min + "分"; 39 | } 40 | return timeDes; 41 | } 42 | 43 | public static String getFriendlyDistance(int m) { 44 | float dis = m / 1000f; 45 | String disDes = fnum.format(dis) + "公里"; 46 | return disDes; 47 | } 48 | 49 | /** 50 | * 计算path对应的标签 51 | * 52 | * @param paths 多路径规划回调的所有路径 53 | * @param ints 多路径线路ID 54 | * @param pathIndex 当前路径索引 55 | * @param strategyBean 封装策略bean 56 | * @return path对应标签描述 57 | */ 58 | public static String getStrategyDes(HashMap paths, int[] ints, int pathIndex, StrategyBean strategyBean) { 59 | int StrategyTAGIndex = pathIndex + 1; 60 | String StrategyTAG = "方案" + StrategyTAGIndex; 61 | 62 | int minTime = Integer.MAX_VALUE; 63 | int minDistance = Integer.MAX_VALUE; 64 | int minTrafficLightNumber = Integer.MAX_VALUE; 65 | int minCost = Integer.MAX_VALUE; 66 | for (int i = 0; i < ints.length; i++) { 67 | if (pathIndex == i) { 68 | continue; 69 | } 70 | AMapNaviPath path = paths.get(ints[i]); 71 | if (path == null) { 72 | continue; 73 | } 74 | int trafficListNumber = getTrafficNumber(path); 75 | if (trafficListNumber < minTrafficLightNumber) { 76 | minTrafficLightNumber = trafficListNumber; 77 | } 78 | 79 | if (path.getTollCost() < minCost) { 80 | minCost = path.getTollCost(); 81 | } 82 | 83 | if (path.getAllTime() < minTime) { 84 | minTime = path.getAllTime(); 85 | } 86 | if (path.getAllLength() < minDistance) { 87 | minDistance = path.getAllLength(); 88 | } 89 | } 90 | AMapNaviPath indexPath = paths.get(ints[pathIndex]); 91 | int indexTrafficLightNumber = getTrafficNumber(indexPath); 92 | int indexCost = indexPath.getTollCost(); 93 | int indexTime = indexPath.getAllTime(); 94 | int indexDistance = indexPath.getAllLength(); 95 | if (indexTrafficLightNumber < minTrafficLightNumber) { 96 | StrategyTAG = "红绿灯少"; 97 | } 98 | if (indexCost < minCost) { 99 | StrategyTAG = "收费较少"; 100 | } 101 | 102 | if (Math.round(indexDistance / 100f) < Math.round(minDistance / 100f)) { // 展示距离精确到千米保留一位小数,比较时按照展示数据处理 103 | StrategyTAG = "距离最短"; 104 | } 105 | if (indexTime / 60 < minTime / 60) { //展示时间精确到分钟,比较时按照展示数据处理 106 | StrategyTAG = "时间最短"; 107 | } 108 | boolean isMulti = isMultiStrategy(strategyBean); 109 | if (strategyBean.isCongestion() && pathIndex == 0 && !isMulti) { 110 | StrategyTAG = "躲避拥堵"; 111 | } 112 | if (strategyBean.isAvoidhightspeed() && pathIndex == 0 && !isMulti) { 113 | StrategyTAG = "不走高速"; 114 | } 115 | if (strategyBean.isCost() && pathIndex == 0 && !isMulti) { 116 | StrategyTAG = "避免收费"; 117 | } 118 | if (pathIndex == 0 && StrategyTAG.startsWith("方案")) { 119 | StrategyTAG = "推荐"; 120 | } 121 | return StrategyTAG; 122 | } 123 | 124 | 125 | /** 126 | * 判断驾车偏好设置是否同时选中多个策略 127 | * 128 | * @param strategyBean 驾车策略bean 129 | * @return 130 | */ 131 | public static boolean isMultiStrategy(StrategyBean strategyBean) { 132 | boolean isMultiStrategy = false; 133 | if (strategyBean.isCongestion()) { 134 | if (strategyBean.isAvoidhightspeed() || strategyBean.isCost() || strategyBean.isHightspeed()) { 135 | isMultiStrategy = true; 136 | } else { 137 | isMultiStrategy = false; 138 | } 139 | } 140 | if (strategyBean.isCost()) { 141 | if (strategyBean.isCongestion() || strategyBean.isAvoidhightspeed()) { 142 | isMultiStrategy = true; 143 | } else { 144 | isMultiStrategy = false; 145 | } 146 | } 147 | if (strategyBean.isAvoidhightspeed()) { 148 | if (strategyBean.isCongestion() || strategyBean.isCost()) { 149 | isMultiStrategy = true; 150 | } else { 151 | isMultiStrategy = false; 152 | } 153 | } 154 | if (strategyBean.isHightspeed()) { 155 | if (strategyBean.isCongestion()) { 156 | isMultiStrategy = true; 157 | } else { 158 | isMultiStrategy = false; 159 | } 160 | } 161 | return isMultiStrategy; 162 | } 163 | 164 | public static Spanned getRouteOverView(AMapNaviPath path) { 165 | String routeOverView = ""; 166 | if (path == null) { 167 | Html.fromHtml(routeOverView); 168 | } 169 | 170 | int cost = path.getTollCost(); 171 | if (cost > 0) { 172 | routeOverView += "过路费约" + cost + "元"; 173 | } 174 | int trafficLightNumber = getTrafficNumber(path); 175 | if (trafficLightNumber > 0) { 176 | routeOverView += "红绿灯" + trafficLightNumber + "个"; 177 | } 178 | return Html.fromHtml(routeOverView); 179 | } 180 | 181 | public static int getTrafficNumber(AMapNaviPath path) { 182 | int trafficLightNumber = 0; 183 | if (path == null) { 184 | return trafficLightNumber; 185 | } 186 | List steps = path.getSteps(); 187 | for (AMapNaviStep step : steps) { 188 | trafficLightNumber += step.getTrafficLightNumber(); 189 | } 190 | return trafficLightNumber; 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_calculate_route.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |