Google 지역 정보에 등록 된 전화 번호가있는 가장 가까운 매장을 찾을 수있는 신청서를 작성 중입니다. 나는이 주소에서 사용할 수있는 잘 알려진 코드 세트도 사용하고있다. - http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/.전화 번호가있는 Google 지역 정보 검색 결과
다운로드 된 코드를 그대로 실행하면 ("radius"대신 "rankby"만 포함) 코드가 정상적으로 실행됩니다. 그러나 전화 번호로 결과를 필터링하기 위해 'if'를 추가했습니다. 결과를 전혀 반환하지 않습니다. 그리고 나는 MainActivity에서 GooglePlaces.getPlaceDetails (참조)를 호출 할 때 예외가 발생한다는 것을 알았습니다. 하지만 SinglePlaceActivity에서 잘 작동합니다. 하나의 활동에서 Google place API를 두 번 호출 할 수는 없습니까?
MainActivity (If 절을 구현하지 않고)를 다른 활동으로 변경하고 새로운 MainActivity에서 아무 것도 전달하지 않고 호출하면 응용 프로그램이 종료되는 오류가 발생합니다. 나는이 두 문제가 서로 연결되어 있다고 생각하므로 함께 묻습니다. 사전에
감사합니다 ...
변경 후 내 MainActivity.java의필요한 부분
protected String doInBackground(String... args) {
// creating Places class object
googlePlaces = new GooglePlaces();
try {
String types = "store"; // Listing places only ambulances
// get nearest places
nearPlaces = googlePlaces.search(gps.getLatitude(), gps.getLongitude(), types);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed Places into LISTVIEW
* */
// Get json response status
String status = nearPlaces.status;
// Check for all possible status
if(status.equals("OK")){
// Successfully got places details
if (nearPlaces.results != null) {
// loop through each place
googlePlaceDetails = new GooglePlaces();
for (Place p : nearPlaces.results) {
try {
PlaceID = p.reference;
placeDetails = googlePlaceDetails.getPlaceDetails(PlaceID);
txtPhone = placeDetails.result.formatted_phone_number;
} catch (Exception e)
{
}
if (txtPhone!=null){
HashMap<String, String> map = new HashMap<String, String>();
map.put(KEY_REFERENCE, p.reference);
map.put(KEY_NAME, p.name);
placesListItems.add(map);
}
}
ListAdapter adapter = new SimpleAdapter(MainActivity.this, placesListItems,
R.layout.list_item,
new String[] { KEY_REFERENCE, KEY_NAME}, new int[] {
R.id.reference, R.id.name });
lv.setAdapter(adapter);
}
}
else if(status.equals("ZERO_RESULTS")){
// Zero results found
alert.showAlertDialog(MainActivity.this, "Near Places",
"Sorry no places found. Try to change the types of places",
false);
}
else if(status.equals("UNKNOWN_ERROR"))
{
alert.showAlertDialog(MainActivity.this, "Places Error",
"Sorry unknown error occured.",
false);
}
else if(status.equals("OVER_QUERY_LIMIT"))
{
alert.showAlertDialog(MainActivity.this, "Places Error",
"Sorry query limit to google places is reached",
false);
}
else if(status.equals("REQUEST_DENIED"))
{
alert.showAlertDialog(MainActivity.this, "Places Error",
"Sorry error occured. Request is denied",
false);
}
else if(status.equals("INVALID_REQUEST"))
{
alert.showAlertDialog(MainActivity.this, "Places Error",
"Sorry error occured. Invalid Request",
false);
}
else
{
alert.showAlertDialog(MainActivity.this, "Places Error",
"Sorry error occured.",
false);
}
}
});
}
}
내 GooglePlaces.java 파일을 변경하고,하지 않은이 매우 잘 알려진 코드는 그대로 나는 그것을 업로드하고 있지 않다. 누구든지 나를 도울 수 있다면 나를 위해 엄청난 도움이 될 것입니다 ...
다시 감사드립니다.
Schakraborty 내가 같은 자습서를 다음 있어요하지만 난 어딘가에 붙어있어 그래서 난이 링크를 따라하지만 그것은 단지 근처의 장소는 전화 번호와 같은 다른 세부 사항을 구현할 수를 생성합니다 .... HTTP : //www.androidbegin.com/tutorial/implementing-actionbarsherlock-search-collapsible-view-in-android/ – Aravin
전화 번호 받기에 대해 참조하십시오. http://stackoverflow.com/questions/14028128/displaying-formatted-phone- google-places-the-a-alert-dialog-o-rq = 1 – Aravin
Aravinth에게 감사하지만, 이미 제공 한 두 번째 링크를 통과했지만 도움이 될만한 것을 찾을 수 없었습니다. 나를. 그리고 첫 번째 링크에 대해서는 실수로 다른 링크를 게시 한 것 같습니다. – sChakraborty