0
package com.example.restaurantfinder;

public class SearchBarActivity extends Activity implements LocationListener{
protected LocationManager locationManager;
protected LocationListener locationListener;
protected Context context;
private EditText mSearchTerm;
String ll;
String provider;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
setContentView(R.layout.search_layout);
setTitle("Search using yelp");
mSearchTerm = (EditText)findViewById(R.id.searchTerm);
}
@Override
**public void onLocationChanged(Location location) {
ll = location.getLatitude() + "," + location.getLongitude();
}**

public void search(View v) {
    String term = mSearchTerm.getText().toString();
    Intent intent = new Intent(this, YelpSearchListActivity.class);
    intent.setData(new Uri.Builder().appendQueryParameter("term", term).**appendQueryParameter("ll", ll)**.appendQueryParameter("radius_filter","5000").build());

    startActivity(intent);
}

}

I am new to Java and android.What I want to do is calculate longitude and latitude as the location changes and pass it on to my query appendQueryParameter("ll", /* function*/). How can I do this?

Rahul Kumar
  • 73
  • 1
  • 9

1 Answers1

0

I found something similar at - Android: How to get location information from intent bundle extras when using LocationManager.requestLocationUpdates()

Community
  • 1
  • 1
TechnoBlahble
  • 633
  • 5
  • 14
  • Thanks for your reply. I get the location update thing. But most important thing which I am trying to figure it out is how to store longitude and latitude parameters at particular instant and then pass it to query. For example i want to covert latitude and longitude to string combine them and pass it in to second ll parameter in query below: intent.setData(new Uri.Builder().appendQueryParameter("term", term).**appendQueryParameter("ll", **ll**) – Rahul Kumar Jun 03 '15 at 16:04
  • So whats the exact issue? Is it that you are not receving location updates when the location changes, or is that you are not able to pass it correctly in the intent ? – TechnoBlahble Jun 03 '15 at 18:42