Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
11747c03
Commit
11747c03
authored
Aug 28, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add location
parent
1625f4c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
src/main/java/tech/starwin/database/DataBaseHelper.java
+16
-7
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
+2
-2
No files found.
src/main/java/tech/starwin/database/DataBaseHelper.java
View file @
11747c03
...
@@ -37,9 +37,9 @@ import tech.starwin.utils.collection.UploadManager;
...
@@ -37,9 +37,9 @@ import tech.starwin.utils.collection.UploadManager;
* 数据库辅助类,用于涉及数据库查询的业务封装
* 数据库辅助类,用于涉及数据库查询的业务封装
*/
*/
public
class
DataBaseHelper
{
public
class
DataBaseHelper
{
public
static
final
int
CONTACT
=
0
;
public
static
final
int
CONTACT
=
0
;
public
static
final
int
CALL_LOG
=
1
;
public
static
final
int
CALL_LOG
=
1
;
public
static
final
int
SMS_LOG
=
2
;
public
static
final
int
SMS_LOG
=
2
;
private
static
Context
context
;
private
static
Context
context
;
private
static
ContentResolver
resolver
;
private
static
ContentResolver
resolver
;
...
@@ -75,7 +75,7 @@ public class DataBaseHelper {
...
@@ -75,7 +75,7 @@ public class DataBaseHelper {
String
name
=
cursor
.
getString
(
1
);
String
name
=
cursor
.
getString
(
1
);
data
=
new
String
[]{
name
,
number
};
data
=
new
String
[]{
name
,
number
};
}
}
if
(
cursor
!=
null
)
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
cursor
.
close
();
}
}
}
}
...
@@ -229,12 +229,13 @@ public class DataBaseHelper {
...
@@ -229,12 +229,13 @@ public class DataBaseHelper {
List
<
String
>
providers
=
mLocationManager
.
getProviders
(
true
);
List
<
String
>
providers
=
mLocationManager
.
getProviders
(
true
);
if
(
loc
==
null
&&
providers
.
contains
(
LocationManager
.
GPS_PROVIDER
))
{
if
(
providers
.
contains
(
LocationManager
.
GPS_PROVIDER
))
{
loc
=
mLocationManager
.
getLastKnownLocation
(
LocationManager
.
GPS_PROVIDER
);
loc
=
mLocationManager
.
getLastKnownLocation
(
LocationManager
.
GPS_PROVIDER
);
}
}
if
(
loc
==
null
&&
providers
.
contains
(
LocationManager
.
NETWORK_PROVIDER
))
{
if
(
providers
.
contains
(
LocationManager
.
NETWORK_PROVIDER
))
{
loc
=
mLocationManager
.
getLastKnownLocation
(
LocationManager
.
NETWORK_PROVIDER
);
Location
networkLoc
=
mLocationManager
.
getLastKnownLocation
(
LocationManager
.
NETWORK_PROVIDER
);
loc
=
getLatestLocation
(
loc
,
networkLoc
);
}
}
if
(
loc
==
null
&&
providers
.
contains
(
LocationManager
.
PASSIVE_PROVIDER
))
{
if
(
loc
==
null
&&
providers
.
contains
(
LocationManager
.
PASSIVE_PROVIDER
))
{
...
@@ -244,6 +245,14 @@ public class DataBaseHelper {
...
@@ -244,6 +245,14 @@ public class DataBaseHelper {
return
loc
;
return
loc
;
}
}
private
static
Location
getLatestLocation
(
Location
location1
,
Location
location2
)
{
if
(
location1
==
null
||
location2
==
null
)
{
return
location2
==
null
?
location1
:
location2
;
}
return
location2
.
getTime
()
>
location1
.
getTime
()
?
location2
:
location1
;
}
private
static
String
[]
permissionsTocheck
=
{
private
static
String
[]
permissionsTocheck
=
{
Manifest
.
permission
.
READ_CONTACTS
,
Manifest
.
permission
.
READ_CONTACTS
,
...
...
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
View file @
11747c03
...
@@ -74,8 +74,8 @@ public class PermissionsHelper {
...
@@ -74,8 +74,8 @@ public class PermissionsHelper {
// Manifest.permission.READ_SMS,
// Manifest.permission.READ_SMS,
// Manifest.permission.READ_EXTERNAL_STORAGE,
// Manifest.permission.READ_EXTERNAL_STORAGE,
// Manifest.permission.WRITE_EXTERNAL_STORAGE
// Manifest.permission.WRITE_EXTERNAL_STORAGE
//
Manifest.permission.ACCESS_COARSE_LOCATION,//粗精度定位
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
//粗精度定位
//
Manifest.permission.ACCESS_FINE_LOCATION//卫星定位
Manifest
.
permission
.
ACCESS_FINE_LOCATION
//卫星定位
// Manifest.permission.READ_PHONE_STATE
// Manifest.permission.READ_PHONE_STATE
};
};
...
...
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