Hello, This is baffling me. It must be something that I am doing wrong fundamentally, but for the life of me I can't see it Can a good soul help me please?
I am (supposedly) catching NullPointerException and returning 0 if that happens. But occasionally I get NullPointerException failure anyway. Is catching it this way no enough to prevent this failure? Thanks for your help. private char getCharBehindCursor (int offset){ // get a single char behind cursor + offsett CharSequence cSeq; InputConnection inputConnection = getCurrentInputConnection(); unicode if (inputConnection != null){ try { cSeq = inputConnection.getTextBeforeCursor (offset + 1, 0); } catch (NullPointerException npe) { /* failure*/ return (char)0; } if (cSeq.length() == offset+1){ // if we got enough characters return cSeq.charAt(0); // we always want the first one in the returned string } } return (char)0; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en