Activity 클래스에서 JobService로 위도 및 경도 값을 가져 오려고합니다. 어떻게해야합니까? putExtras 등으로 인 텐트를 사용해 보았지만 (아래 코드를 보아라.), 제대로 만들 수 없었다.Activity에서 JobService로 데이터 전달
MainActivity.class
protected void createLocationRequest(Bundle bundle) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, new LocationCallback() {
@Override
public void onLocationResult(final LocationResult locationResult) {
Log.i("onLocationResult", locationResult + "");
latitude = locationResult.getLastLocation().getLatitude() + "";
longitude = locationResult.getLastLocation().getLongitude() + "";
Log.e("onLocationResult lat", latitude);
Log.e("onLocationResult Lon", longitude);
//I need to send latitude and longitude value to jobService?
//how to do that?
//tried using intent but didn't seem to work
//Intent mIntent = new Intent();
//mIntent.putExtra("lat", latitude);
//mIntent.putExtra("lon", longitude);
}
}, null);
}
MyJobService 클래스
public class MyJobService extends JobService {
@Override
public boolean onStartJob(JobParameters jobParameters) {
//I need to get latitude and longitude value here from mainActivity
return true;
}
}