locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
if(Geocoder.isPresent()){
Geocoder gcd = new Geocoder(context, Locale.getDefault());
try {
List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1);
if(addresses != null) {
Address returnedAddress = addresses.get(0);
StringBuilder strReturnedAddress = new StringBuilder("Address:\n");
for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {
strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
}
weatherLocation = strReturnedAddress.toString();
}
}
catch (IOException e) {
e.printStackTrace();
}
}
IDE にエラーはありません。考えられることはすべて試しました。このメソッドが実行されるたびに、アプリケーションがクラッシュします (これがそのメソッドの唯一のコードです)。
ログキャット:
07-10 00:59:37.160: I/TextToSpeech(11319): Connected to ComponentInfo{com.google.android.tts/com.google.android.tts.GoogleTTSService}
07-10 00:59:45.065: D/AndroidRuntime(11319): Shutting down VM
07-10 00:59:45.065: W/dalvikvm(11319): threadid=1: thread exiting with uncaught exception (group=0x41471930)
07-10 00:59:45.075: E/AndroidRuntime(11319): FATAL EXCEPTION: main
07-10 00:59:45.075: E/AndroidRuntime(11319): java.lang.IllegalStateException: Could not find a method registermessage(View) in the activity class com.example.realapptest1.MainActivity for onClick handler on view class android.widget.Button with id 'button1'
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.view.View$1.onClick(View.java:3593)
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.view.View.performClick(View.java:4211)
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.view.View$PerformClick.run(View.java:17362)
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.os.Handler.handleCallback(Handler.java:725)
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.os.Handler.dispatchMessage(Handler.java:92)
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.os.Looper.loop(Looper.java:137)
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.app.ActivityThread.main(ActivityThread.java:5222)
07-10 00:59:45.075: E/AndroidRuntime(11319): at java.lang.reflect.Method.invokeNative(Native Method)
07-10 00:59:45.075: E/AndroidRuntime(11319): at java.lang.reflect.Method.invoke(Method.java:511)
07-10 00:59:45.075: E/AndroidRuntime(11319): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
07-10 00:59:45.075: E/AndroidRuntime(11319): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
07-10 00:59:45.075: E/AndroidRuntime(11319): at dalvik.system.NativeStart.main(Native Method)
07-10 00:59:45.075: E/AndroidRuntime(11319): Caused by: java.lang.NoSuchMethodException: registermessage [class android.view.View]
07-10 00:59:45.075: E/AndroidRuntime(11319): at java.lang.Class.getConstructorOrMethod(Class.java:460)
07-10 00:59:45.075: E/AndroidRuntime(11319): at java.lang.Class.getMethod(Class.java:915)
07-10 00:59:45.075: E/AndroidRuntime(11319): at android.view.View$1.onClick(View.java:3586)
07-10 00:59:45.075: E/AndroidRuntime(11319): ... 11 more
クラッシュの Logcat。