2012-10-05 32 views
1

我的手機上有這個奇怪的錯誤(不是模擬器)。 我寫了一個代碼一個edittext導航到第一個輸入結果的按鈕。 它工作了幾天,當我繼續devlopibg它突然停止工作。 什麼是奇怪的是,我安裝了一個早期版本,並沒有奏效。 自從特定的代碼部分沒有改變! 另外,我在不同的手機上安裝了最新版本,並且突然間它也沒有工作。 我不知道如何解決它,我不明白爲什麼我會得到這個錯誤。 爲什麼它突然說服務不可用,如果它以前工作? 這是代碼:android - geocoder.getfromlocationname返回服務不可用

configure Search button//Button btn_search = (Button)findViewById(R.id.map_ ;(search_button if(!came_from.matches(" (("FollowLocation } ;(btn_search.setEnabled(false { btn_search.setOnClickListener(}()new OnClickListener } (public void onClick(View v final AlertDialog.Builder ;(alert = new AlertDialog.Builder(context final EditText input = new ;(EditText(context input.setHint("Enter ;("Address input.setImeOptions(;(EditorInfo.IME_ACTION_DONE ;(alert.setView(input alert.setPositiveButton("OK", }()new DialogInterface.OnClickListener public void onClick(DialogInterface dialog, int } (whichButton String value = ;()input.getText().toString().trim } try Geocoder geocoder = 

Geocoder(getApplicationContext(), ;(Locale.ENGLISH List<Address> results 

;(geocoder.getFromLocationName(value, 1 

} (if (results.size() == 0 

AlertDialog.Builder builder2 = new ;(AlertDialog.Builder(context 

builder2.setMessage("No Address Found, ("Please Try Again 

(setCancelable(true. 

setNegativeButton("OK", new. }()DialogInterface.OnClickListener public } (void onClick(DialogInterface dialog, int id 

;()dialog.cancel { ({ ;()show. { else } Address ;(address = results.get(0 GeoPoint p = (new GeoPoint((int address.getLatitude() * 1E6), (int)) ;(((address.getLongitude() * 1E6 gMapView = ;((MapView) findViewById(R.id.myGMap mc = ;()gMapView.getController 

;(mc.setZoom(18 

;(mc.animateTo(p 

remove//previous overlays and put this location as circle 

;()gMapView.getOverlays().clear Add a // 

MyLocationOverlay circleOverlay = new ;()MyLocationOverlay 

;circleOverlay.circle=true list = ;()gMapView.getOverlays 

;(list.add(circleOverlay { 

} (catch (Exception e { 

AlertDialog.Builder builder2 = new ;(AlertDialog.Builder(context 

builder2.setMessage("Error. Please check 

(".internet connection 

(setCancelable(true. 

setNegativeButton("OK", new. }()DialogInterface.OnClickListener public } (void onClick(DialogInterface dialog, int id 

;()dialog.cancel { ({ ;()show. { 

{ ;({ alert.setNegativeButton(" Cancel", new }()DialogInterface.OnClickListener public void onClick(DialogInterface dialog, int } (whichButton ;()dialog.cancel { ;({ ;()alert.show { ;({ 
+2

請以正確的方式粘貼您的代碼。 – Lucifer

回答

3

回答我的問題是重新啓動我的電話。

+0

儘管答案看起來很蹩腳,但答案卻是毫不遜色。我有ICS ph和JB xoom都拋出異常並重新啓動它們,因爲它們都是作爲回答工作的。 –

+0

這是第十一條誡命:你不知道發生了什麼。 – Androiderson

相關問題