Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KeepMeSafe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vivek s
KeepMeSafe
Commits
7ea8c78d
Commit
7ea8c78d
authored
Apr 18, 2017
by
Subash N
Committed by
GitHub
Apr 18, 2017
Browse files
Options
Downloads
Patches
Plain Diff
Add files via upload
parent
2fddcaeb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/com/speedyapps/keepyousafe/GpsTool.java
+87
-0
87 additions, 0 deletions
app/src/main/java/com/speedyapps/keepyousafe/GpsTool.java
with
87 additions
and
0 deletions
app/src/main/java/com/speedyapps/keepyousafe/GpsTool.java
0 → 100644
+
87
−
0
View file @
7ea8c78d
package
com.speedyapps.keepyousafe
;
/**
* Created by SUBASH on 18-04-2017.
*/
import
android.content.Context
;
import
android.content.Intent
;
import
android.location.Location
;
import
android.location.LocationListener
;
import
android.location.LocationManager
;
import
android.os.Bundle
;
import
android.provider.Settings
;
/**
* Created by pethoalpar on 4/13/2016.
*/
public
class
GpsTool
{
String
locationProvider
=
LocationManager
.
GPS_PROVIDER
;
private
LocationManager
locationManager
;
private
LocationListener
locationListener
;
public
GpsTool
(
Context
context
){
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
this
.
turnOnGps
(
context
);
locationListener
=
new
LocationListener
()
{
@Override
public
void
onLocationChanged
(
Location
location
)
{
onGpsLocationChanged
(
location
);
location
.
reset
();
}
@Override
public
void
onStatusChanged
(
String
provider
,
int
status
,
Bundle
extras
)
{
onGpsStatusChanged
(
provider
,
status
,
extras
);
}
@Override
public
void
onProviderEnabled
(
String
provider
)
{
onGpsProviderEnabled
(
provider
);
}
@Override
public
void
onProviderDisabled
(
String
provider
)
{
onGpsProviderDisabled
(
provider
);
}
};
startGpsUpdate
();
}
public
void
onGpsLocationChanged
(
Location
location
)
{
//Location change.
}
public
void
onGpsStatusChanged
(
String
provider
,
int
status
,
Bundle
extras
)
{
}
public
void
onGpsProviderEnabled
(
String
provider
)
{
}
public
void
onGpsProviderDisabled
(
String
provider
)
{
}
public
Location
getLocation
(){
return
locationManager
.
getLastKnownLocation
(
locationProvider
);
}
public
void
startGpsUpdate
(){
locationManager
.
requestLocationUpdates
(
locationProvider
,
1000
,
0
,
locationListener
);
}
public
void
stopGpsUpdate
(){
locationManager
.
removeUpdates
(
locationListener
);
}
public
void
turnOnGps
(
Context
context
){
boolean
isEnabled
=
locationManager
.
isProviderEnabled
(
locationProvider
);
if
(!
isEnabled
){
Intent
intent
=
new
Intent
(
Settings
.
ACTION_LOCATION_SOURCE_SETTINGS
);
context
.
startActivity
(
intent
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment