I am getting unsupported operation exception while running my Android Code, RANDOMLY. Once this exception is thrown, my application is crashed. How to handle the same , and what is the basic cause of this EXCEPTION to be thrown.
Example 1:
@Override
public View getSelectedView() {
throw new UnsupportedOperationException("Not supported");
}
Example 2:
@Override
public void onBackPressed() {
if(slideContent.getVisibility()==View.VISIBLE)
slideContent.setVisibility(View.GONE);
if(searchAutoCompleteText.getText().toString().length()>0)
searchAutoCompleteText.setText("");
else{
super.onBackPressed();
}
}
LogCat:
java.lang.UnsupportedOperationException
com.artifex.mupdfdemo.ReaderView.getSelectedView(ReaderView.java:751)
android.widget.AdapterView.onInitializeAccessibilityEvent(AdapterView.java:1014)
android.view.View.sendAccessibilityEventUncheckedInternal(View.java:5150)
android.view.View.sendAccessibilityEventUnchecked(View.java:5135)
android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.run(ViewRootImpl.java:7463)
android.os.Handler.handleCallback(Handler.java:733)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:157)
android.app.ActivityThread.main(ActivityThread.java:5335)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
dalvik.system.NativeStart.main(Native Method)
The above written are few scenarios where I get UNSUPPORTEDOperationException and the Application Crashed. Please let me know the ROOT CAUSE, if anybody knows the same.
return null instead of
UnsupportedOperationException
check this