Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
R
RatelVirtualLocation
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
RatelVirtualLocation
Commits
a9de60d8
Commit
a9de60d8
authored
Aug 26, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级百度地图api版本
parent
aff2b4c3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
236 additions
and
26 deletions
+236
-26
build.gradle
app/build.gradle
+5
-3
BaiduLBS_Android.jar
app/libs/BaiduLBS_Android.jar
+0
-0
BaiduLBS_aar_android.aar
app/libs/BaiduLBS_aar_android.aar
+0
-0
MainActivity.java
...top/littlerich/virtuallocation/activity/MainActivity.java
+13
-13
AppApplication.java
...top/littlerich/virtuallocation/common/AppApplication.java
+13
-8
MapClickListener.java
...littlerich/virtuallocation/listener/MapClickListener.java
+2
-2
LocationService.java
...p/littlerich/virtuallocation/service/LocationService.java
+172
-0
Utils.java
...in/java/top/littlerich/virtuallocation/service/Utils.java
+31
-0
libBaiduMapSDK_v3_2_0_15.so
app/src/main/jniLibs/armeabi-v7a/libBaiduMapSDK_v3_2_0_15.so
+0
-0
liblocSDK5.so
app/src/main/jniLibs/armeabi-v7a/liblocSDK5.so
+0
-0
No files found.
app/build.gradle
View file @
a9de60d8
...
...
@@ -9,7 +9,7 @@ android {
versionCode
20200825
versionName
"v1.0.0"
ndk
{
abiFilters
"armeabi-v7a"
//, "arm64-v8a"
, "x86","arm64-v8a","x86_64"
abiFilters
"armeabi-v7a"
,
"arm64-v8a"
//
, "x86","arm64-v8a","x86_64"
}
}
buildTypes
{
...
...
@@ -20,8 +20,9 @@ android {
}
sourceSets
{
main
{
jniLibs
.
srcDir
s
=
[
'src/main/jniLibs'
]
jniLibs
.
srcDir
'libs'
}
}
lintOptions
{
...
...
@@ -31,8 +32,9 @@ android {
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
implementation
fileTree
(
include:
[
'*.aar'
],
dir:
'libs'
)
provided
files
(
'jar/XposedBridgeApi-54.jar'
)
compile
files
(
'libs/BaiduLBS_Android.j
ar'
)
// implementation(name: 'BaiduLBS_aar_android', ext: 'a
ar')
// jniLibs.srcDir 'src/main/jniLibs'
implementation
'com.android.support:appcompat-v7:28.0.0'
//implementation 'com.android.support.constraint:constraint-layout:2.0.0-rc1'
...
...
app/libs/BaiduLBS_Android.jar
deleted
100644 → 0
View file @
aff2b4c3
File deleted
app/libs/BaiduLBS_aar_android.aar
0 → 100644
View file @
a9de60d8
File added
app/src/main/java/top/littlerich/virtuallocation/activity/MainActivity.java
View file @
a9de60d8
...
...
@@ -91,24 +91,24 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
PermissionUtil
.
requestPermissions
(
this
,
new
String
[]{
Manifest
.
permission
.
READ_PHONE_STATE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
},
99
);
//
PermissionUtil.requestPermissions(this,
//
new String[]{
//
Manifest.permission.READ_PHONE_STATE,
//
Manifest.permission.WRITE_EXTERNAL_STORAGE,
//
Manifest.permission.ACCESS_FINE_LOCATION},
//
99);
super
.
onCreate
(
savedInstanceState
);
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
if
(
PermissionUtil
.
checkPermission
(
this
,
Manifest
.
permission
.
READ_PHONE_STATE
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
// 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
SDKInitializer
.
initialize
(
this
);
}
else
{
Toast
.
makeText
(
this
,
"没有权限,无法工作"
,
Toast
.
LENGTH_SHORT
).
show
();
}
//
if (PermissionUtil.checkPermission(this, Manifest.permission.READ_PHONE_STATE)
//
== PackageManager.PERMISSION_GRANTED) {
//
// 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
//
SDKInitializer.initialize(this);
//
} else {
//
Toast.makeText(this, "没有权限,无法工作", Toast.LENGTH_SHORT).show();
//
}
}
@Override
...
...
app/src/main/java/top/littlerich/virtuallocation/common/AppApplication.java
View file @
a9de60d8
package
top
.
littlerich
.
virtuallocation
.
common
;
import
android.Manifest
;
import
android.app.Application
;
import
android.content.pm.PackageManager
;
import
android.app.Service
;
import
android.os.Vibrator
;
import
com.baidu.mapapi.CoordType
;
import
com.baidu.mapapi.SDKInitializer
;
import
top.littlerich.virtuallocation.model.Gps
;
import
top.littlerich.virtuallocation.
util.PermissionUtil
;
import
top.littlerich.virtuallocation.
service.LocationService
;
/**
* Created by xuqingfu on 2017/4/15.
*/
public
class
AppApplication
extends
Application
{
public
LocationService
locationService
;
public
Vibrator
mVibrator
;
/**
* 全局GPS
...
...
@@ -26,11 +29,13 @@ public class AppApplication extends Application {
@Override
public
void
onCreate
()
{
super
.
onCreate
();
if
(
PermissionUtil
.
checkPermission
(
this
,
Manifest
.
permission
.
READ_PHONE_STATE
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
// 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
SDKInitializer
.
initialize
(
this
);
}
/***
* 初始化定位sdk,建议在Application中创建
*/
locationService
=
new
LocationService
(
getApplicationContext
());
mVibrator
=
(
Vibrator
)
getApplicationContext
().
getSystemService
(
Service
.
VIBRATOR_SERVICE
);
SDKInitializer
.
initialize
(
getApplicationContext
());
SDKInitializer
.
setCoordType
(
CoordType
.
BD09LL
);
}
}
\ No newline at end of file
app/src/main/java/top/littlerich/virtuallocation/listener/MapClickListener.java
View file @
a9de60d8
...
...
@@ -39,7 +39,7 @@ public class MapClickListener implements BaiduMap.OnMapClickListener {
* @return
*/
@Override
public
boolean
onMapPoiClick
(
MapPoi
mapPoi
)
{
return
false
;
public
void
onMapPoiClick
(
MapPoi
mapPoi
)
{
//
return false;
}
}
app/src/main/java/top/littlerich/virtuallocation/service/LocationService.java
0 → 100755
View file @
a9de60d8
package
top
.
littlerich
.
virtuallocation
.
service
;
import
android.content.Context
;
import
android.webkit.WebView
;
import
com.baidu.location.BDAbstractLocationListener
;
import
com.baidu.location.LocationClient
;
import
com.baidu.location.LocationClientOption
;
import
com.baidu.location.LocationClientOption.LocationMode
;
/**
* 定位服务LocationClient 相关
*
* @author baidu
*/
public
class
LocationService
{
private
static
LocationClient
client
=
null
;
private
static
LocationClientOption
mOption
;
private
static
LocationClientOption
DIYoption
;
private
Object
objLock
;
/***
* 初始化 LocationClient
*
* @param locationContext
*/
public
LocationService
(
Context
locationContext
)
{
objLock
=
new
Object
();
synchronized
(
objLock
)
{
if
(
client
==
null
)
{
client
=
new
LocationClient
(
locationContext
);
client
.
setLocOption
(
getDefaultLocationClientOption
());
}
}
}
/***
* 注册定位监听
*
* @param listener
* @return
*/
public
boolean
registerListener
(
BDAbstractLocationListener
listener
)
{
boolean
isSuccess
=
false
;
if
(
listener
!=
null
)
{
client
.
registerLocationListener
(
listener
);
isSuccess
=
true
;
}
return
isSuccess
;
}
public
void
unregisterListener
(
BDAbstractLocationListener
listener
)
{
if
(
listener
!=
null
)
{
client
.
unRegisterLocationListener
(
listener
);
}
}
/**
* @return 获取sdk版本
*/
public
String
getSDKVersion
()
{
if
(
client
!=
null
)
{
String
version
=
client
.
getVersion
();
return
version
;
}
return
null
;
}
/***
* 设置定位参数
*
* @param option
* @return isSuccessSetOption
*/
public
static
boolean
setLocationOption
(
LocationClientOption
option
)
{
boolean
isSuccess
=
false
;
if
(
option
!=
null
)
{
if
(
client
.
isStarted
())
{
client
.
stop
();
}
DIYoption
=
option
;
client
.
setLocOption
(
option
);
}
return
isSuccess
;
}
/**
* 开发者应用如果有H5页面使用了百度JS接口,该接口可以辅助百度JS更好的进行定位
*
* @param webView 传入webView控件
*/
public
void
enableAssistanLocation
(
WebView
webView
)
{
if
(
client
!=
null
)
{
client
.
enableAssistantLocation
(
webView
);
}
}
/**
* 停止H5辅助定位
*/
public
void
disableAssistantLocation
()
{
if
(
client
!=
null
)
{
client
.
disableAssistantLocation
();
}
}
/***
*
* @return DefaultLocationClientOption 默认O设置
*/
public
LocationClientOption
getDefaultLocationClientOption
()
{
if
(
mOption
==
null
)
{
mOption
=
new
LocationClientOption
();
mOption
.
setLocationMode
(
LocationMode
.
Hight_Accuracy
);
// 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
mOption
.
setCoorType
(
"bd09ll"
);
// 可选,默认gcj02,设置返回的定位结果坐标系,如果配合百度地图使用,建议设置为bd09ll;
mOption
.
setScanSpan
(
3000
);
// 可选,默认0,即仅定位一次,设置发起连续定位请求的间隔需要大于等于1000ms才是有效的
mOption
.
setIsNeedAddress
(
true
);
// 可选,设置是否需要地址信息,默认不需要
mOption
.
setIsNeedLocationDescribe
(
true
);
// 可选,设置是否需要地址描述
mOption
.
setNeedDeviceDirect
(
false
);
// 可选,设置是否需要设备方向结果
mOption
.
setLocationNotify
(
false
);
// 可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
mOption
.
setIgnoreKillProcess
(
true
);
// 可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop
mOption
.
setIsNeedLocationDescribe
(
true
);
// 可选,默认false,设置是否需要位置语义化结果,可以在BDLocation
mOption
.
setIsNeedLocationPoiList
(
true
);
// 可选,默认false,设置是否需要POI结果,可以在BDLocation
mOption
.
SetIgnoreCacheException
(
false
);
// 可选,默认false,设置是否收集CRASH信息,默认收集
mOption
.
setOpenGps
(
true
);
// 可选,默认false,设置是否开启Gps定位
mOption
.
setIsNeedAltitude
(
false
);
// 可选,默认false,设置定位时是否需要海拔信息,默认不需要,除基础定位版本都可用
}
return
mOption
;
}
/**
* @return DIYOption 自定义Option设置
*/
public
LocationClientOption
getOption
()
{
if
(
DIYoption
==
null
)
{
DIYoption
=
new
LocationClientOption
();
}
return
DIYoption
;
}
public
void
start
()
{
synchronized
(
objLock
)
{
if
(
client
!=
null
&&
!
client
.
isStarted
())
{
client
.
start
();
}
}
}
public
void
requestLocation
()
{
if
(
client
!=
null
)
{
client
.
requestLocation
();
}
}
public
void
stop
()
{
synchronized
(
objLock
)
{
if
(
client
!=
null
&&
client
.
isStarted
())
{
client
.
stop
();
}
}
}
public
boolean
isStart
()
{
return
client
.
isStarted
();
}
public
boolean
requestHotSpotState
()
{
return
client
.
requestHotSpotState
();
}
}
app/src/main/java/top/littlerich/virtuallocation/service/Utils.java
0 → 100755
View file @
a9de60d8
package
top
.
littlerich
.
virtuallocation
.
service
;
public
class
Utils
{
public
final
static
String
CoorType_GCJ02
=
"gcj02"
;
public
final
static
String
CoorType_BD09LL
=
"bd09ll"
;
public
final
static
String
CoorType_BD09MC
=
"bd09"
;
/***
*61 : GPS定位结果,GPS定位成功。
*62 : 无法获取有效定位依据,定位失败,请检查运营商网络或者wifi网络是否正常开启,尝试重新请求定位。
*63 : 网络异常,没有成功向服务器发起请求,请确认当前测试手机网络是否通畅,尝试重新请求定位。
*65 : 定位缓存的结果。
*66 : 离线定位结果。通过requestOfflineLocaiton调用时对应的返回结果。
*67 : 离线定位失败。通过requestOfflineLocaiton调用时对应的返回结果。
*68 : 网络连接失败时,查找本地离线定位时对应的返回结果。
*161: 网络定位结果,网络定位定位成功。
*162: 请求串密文解析失败。
*167: 服务端定位失败,请您检查是否禁用获取位置信息权限,尝试重新请求定位。
*502: key参数错误,请按照说明文档重新申请KEY。
*505: key不存在或者非法,请按照说明文档重新申请KEY。
*601: key服务被开发者自己禁用,请按照说明文档重新申请KEY。
*602: key mcode不匹配,您的ak配置过程中安全码设置有问题,请确保:sha1正确,“;”分号是英文状态;且包名是您当前运行应用的包名,请按照说明文档重新申请KEY。
*501~700:key验证失败,请按照说明文档重新申请KEY。
*/
public
static
float
[]
EARTH_WEIGHT
=
{
0.1f
,
0.2f
,
0.4f
,
0.6f
,
0.8f
};
// 推算计算权重_地球
//public static float[] MOON_WEIGHT = {0.0167f,0.033f,0.067f,0.1f,0.133f};
//public static float[] MARS_WEIGHT = {0.034f,0.068f,0.152f,0.228f,0.304f};
public
final
static
int
RECEIVE_TAG
=
1
;
public
final
static
int
DIAGNOSTIC_TAG
=
2
;
}
app/src/main/jniLibs/armeabi-v7a/libBaiduMapSDK_v3_2_0_15.so
deleted
100644 → 0
View file @
aff2b4c3
File deleted
app/src/main/jniLibs/armeabi-v7a/liblocSDK5.so
deleted
100644 → 0
View file @
aff2b4c3
File deleted
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment