I'm getting the lat and lng from one URL. In my coding, it will be like, if(lat==1.3005060 && lng== 103.8745850) , it will open up up the next class, map.java. else, invalid map.
I've initially declare it as string to display it as text view. Next I've declare it as float in the onClick method, so that it can pass to google map. However, there is force close error occuring. Can someone guide me?
LogCat Error:
08-14 11:07:13.190: E/AndroidRuntime(457): FATAL EXCEPTION: main
08-14 11:07:13.190: E/AndroidRuntime(457): java.lang.IllegalStateException: Could not execute method of the activity
08-14 11:07:13.190: E/AndroidRuntime(457): at android.view.View$1.onClick(View.java:2185)
08-14 11:07:13.190: E/AndroidRuntime(457): at android.view.View.performClick(View.java:2585)
08-14 11:07:13.190: E/AndroidRuntime(457): at android.view.View$PerformClick.run(View.java:9299)
08-14 11:07:13.190: E/AndroidRuntime(457): at android.os.Handler.handleCallback(Handler.java:587)
08-14 11:07:13.190: E/AndroidRuntime(457): at android.os.Handler.dispatchMessage(Handler.java:92)
08-14 11:07:13.190: E/AndroidRuntime(457): at android.os.Looper.loop(Looper.java:130)
08-14 11:07:13.190: E/AndroidRuntime(457): at android.app.ActivityThread.main(ActivityThread.java:3691)
08-14 11:07:13.190: E/AndroidRuntime(457): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 11:07:13.190: E/AndroidRuntime(457): at java.lang.reflect.Method.invoke(Method.java:507)
08-14 11:07:13.190: E/AndroidRuntime(457): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
08-14 11:07:13.190: E/AndroidRuntime(457): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
08-14 11:07:13.190: E/AndroidRuntime(457): at dalvik.system.NativeStart.main(Native Method)
08-14 11:07:13.190: E/AndroidRuntime(457): Caused by: java.lang.reflect.InvocationTargetException
08-14 11:07:13.190: E/AndroidRuntime(457): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 11:07:13.190: E/AndroidRuntime(457): at java.lang.reflect.Method.invoke(Method.java:507)
08-14 11:07:13.190: E/AndroidRuntime(457): at android.view.View$1.onClick(View.java:2180)
08-14 11:07:13.190: E/AndroidRuntime(457): ... 11 more
08-14 11:07:13.190: E/AndroidRuntime(457): Caused by: java.lang.NumberFormatException: latitude
08-14 11:07:13.190: E/AndroidRuntime(457): at org.apache.harmony.luni.util.FloatingPointParser.initialParse(FloatingPointParser.java:114)
08-14 11:07:13.190: E/AndroidRuntime(457): at org.apache.harmony.luni.util.FloatingPointParser.parseFloat(FloatingPointParser.java:319)
08-14 11:07:13.190: E/AndroidRuntime(457): at java.lang.Float.parseFloat(Float.java:323)
08-14 11:07:13.190: E/AndroidRuntime(457): at com.example.fambond.SingleMenuItemActivity.onClick(SingleMenuItemActivity.java:75)
08-14 11:07:13.190: E/AndroidRuntime(457): ... 14 more
part of my code for singlemenu.java
public void onClick(View v) {
//TODO Auto-generated method stub
float lat=Float.parseFloat(KEY_LATITUDE);
float lng =Float.parseFloat(KEY_LONGITUDE);
if(lat==1.3005060 && lng== 103.8745850){
Log.d("coords", "lat: " + KEY_LATITUDE + " long: " + KEY_LONGITUDE);
Intent intent = new Intent(SingleMenuItemActivity.this,map.class);
intent.putExtra("MAP",KEY_LATITUDE.toString());
intent.putExtra("MAP",KEY_LONGITUDE.toString());
startActivity(intent);
}
else
{
Toast.makeText(SingleMenuItemActivity.this, "Invalid MAP", Toast.LENGTH_LONG).show();
}
}