-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Gps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package pmv02.ppr.yuichi10.github.com.joinevents; | ||
|
||
import android.content.Context; | ||
import android.location.Criteria; | ||
import android.location.Location; | ||
import android.location.LocationListener; | ||
import android.location.LocationManager; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
/** | ||
* Created by yuichi on 8/24/15. | ||
*/ | ||
public class Gps implements LocationListener { | ||
|
||
//location manager | ||
private LocationManager mLocationManager; | ||
//Criteria | ||
private Criteria mCriteria; | ||
//provider | ||
private String mProvider; | ||
//Context | ||
Context mContext; | ||
//Longitude Latitude | ||
private double mLongitude = 0; | ||
private double mLatitude = 0; | ||
//get the place or not | ||
boolean isGetPlace = false; | ||
|
||
public interface GetPlaceCallBack{ | ||
public void isGetPlaceCB(); | ||
} | ||
private GetPlaceCallBack _mGetPlaceCallBack; | ||
|
||
public void setCallbacks(GetPlaceCallBack getPlaceCallBack){ | ||
_mGetPlaceCallBack = getPlaceCallBack; | ||
} | ||
|
||
public Gps(Context context){ | ||
this.mContext = context; | ||
mCriteria = new Criteria(); | ||
} | ||
|
||
//setProvider | ||
public void setProvider(){ | ||
mCriteria.setPowerRequirement(Criteria.POWER_LOW); | ||
mCriteria.setAccuracy(Criteria.ACCURACY_COARSE); | ||
mProvider = mLocationManager.getBestProvider(mCriteria, true); | ||
} | ||
|
||
public void setProvider(String accuracy, String power){ | ||
//later | ||
} | ||
|
||
//start gps | ||
public void startGps(){ | ||
mLocationManager = (LocationManager)mContext.getSystemService(Context.LOCATION_SERVICE); | ||
setProvider(); | ||
mLocationManager.requestLocationUpdates(mProvider, 0, 0, this); | ||
Log.d("aaa","start"); | ||
} | ||
|
||
//stop to get place | ||
public void stopGps(){ | ||
mLocationManager.removeUpdates(this); | ||
} | ||
|
||
@Override | ||
public void onLocationChanged(Location location) { | ||
mLongitude = location.getLongitude(); | ||
mLatitude = location.getLatitude(); | ||
Log.d("aaa","changed"); | ||
_mGetPlaceCallBack.isGetPlaceCB(); | ||
} | ||
|
||
@Override | ||
public void onStatusChanged(String provider, int status, Bundle extras) { | ||
|
||
} | ||
|
||
@Override | ||
public void onProviderEnabled(String provider) { | ||
|
||
} | ||
|
||
@Override | ||
public void onProviderDisabled(String provider) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters