Google map 不能用~
这是在程序中的代码:
address_D.setOnClickListener ( new View.OnClickListener () {
@Override
public void onClick(View v) {
String location = address_D.getText ().toString ();
List<Address> addressList;
if (!location.equals ( "" )) {
Geocoder geocoder = new Geocoder ( DisplayActivity.this );
try {
addressList = geocoder.getFromLocationName ( location, 5 );
if (addressList != null) {
for (int i = 0; i < addressList.size (); i++) {
Intent intent = new Intent ( Intent.ACTION_VIEW );
intent.setData ( Uri.parse ( "geo:" + addressList.get ( i ).getLatitude () + "," + addressList.get ( i ).getLongitude () + "?q=" + location ) );
try {
startActivity ( intent );
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(DisplayActivity.this, "This sentence is for checking the error.",Toast.LENGTH_SHORT).show();
}
}
}
} catch (IOException e) {
e.printStackTrace ();
}
} else {
Toast.makeText ( DisplayActivity.this, "This person hasn't given the location yet!", Toast.LENGTH_SHORT ).show ();
}
}
} );
这是在点击该按钮出现提示的 问题;
W/System.err: java.io.IOException: Service not Available
W/System.err: at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
W/System.err: at com.example.txin.family.DisplayActivity$1.onClick(DisplayActivity.java:70)
W/System.err: at android.view.View.performClick(View.java:5215)
W/System.err: at android.view.View$PerformClick.run(View.java:21193)
W/System.err: at android.os.Handler.handleCallback(Handler.java:742)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err: at android.os.Looper.loop(Looper.java:157)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5555)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
Application terminated.