JordanRulz Posted March 19, 2012 Share Posted March 19, 2012 this happens when i try to parseint from a String out of a numberonly EditText: 03-19 04:39:34.597: E/AndroidRuntime(339): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 03-19 04:39:34.597: E/AndroidRuntime(339): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 03-19 04:39:34.597: E/AndroidRuntime(339): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 03-19 04:39:34.597: E/AndroidRuntime(339): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.os.Handler.dispatchMessage(Handler.java:99) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.os.Looper.loop(Looper.java:123) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.app.ActivityThread.main(ActivityThread.java:4363) 03-19 04:39:34.597: E/AndroidRuntime(339): at java.lang.reflect.Method.invokeNative(Native Method) 03-19 04:39:34.597: E/AndroidRuntime(339): at java.lang.reflect.Method.invoke(Method.java:521) 03-19 04:39:34.597: E/AndroidRuntime(339): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 03-19 04:39:34.597: E/AndroidRuntime(339): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 03-19 04:39:34.597: E/AndroidRuntime(339): at dalvik.system.NativeStart.main(Native Method) 03-19 04:39:34.597: E/AndroidRuntime(339): Caused by: java.lang.reflect.InvocationTargetException 03-19 04:39:34.597: E/AndroidRuntime(339): at org.jordanrulz.robotdriver.RobotDriver.connectrobot(RobotDriver.java:45) 03-19 04:39:34.597: E/AndroidRuntime(339): at java.lang.reflect.Method.invokeNative(Native Method) 03-19 04:39:34.597: E/AndroidRuntime(339): at java.lang.reflect.Method.invoke(Method.java:521) 03-19 04:39:34.597: E/AndroidRuntime(339): at android.view.View$1.onClick(View.java:2026) 03-19 04:39:34.597: E/AndroidRuntime(339): ... 22 more 03-19 04:39:34.597: E/AndroidRuntime(339): Caused by: java.lang.NullPointerException 03-19 04:39:34.597: E/AndroidRuntime(339): ... 26 more Quote Link to comment Share on other sites More sharing options...
JordanRulz Posted March 19, 2012 Author Share Posted March 19, 2012 all my code you need to know: public void connectrobot(View v) throws NullPointerException{ String robotip1 = robotip.toString(); String robotport1 = robotport.toString(); try { robotport2 = Integer.parseInt(robotport1); } catch (NumberFormatException e2) { Log.i("NumberFormatException: " ,e2.getMessage()); } try { robotip2 = InetAddress.getByName(robotip1); } catch (UnknownHostException e1) { // TODO Auto-generated catch block conerror.makeText(this, "Error connecting: " + e1.getMessage(), 2); conerror.show(); } try { robotcon = new Socket(robotip2,robotport2); } catch (Exception e) { // TODO Auto-generated catch block conerror.makeText(this, "Error connecting: " + e.getMessage(), 2); conerror.show(); } conerror is a Toast robotip is a text EditText robotport is a numberonly EditText this is for a robot i need to make for a school project Quote Link to comment Share on other sites More sharing options...
zibizzz Posted March 26, 2012 Share Posted March 26, 2012 try: robotport.gettext().toString() also check for null in robotport Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.