Buggy code:
public class ViewZenossDevice extends Activity { ZenossAPIv2 API = null ; JSONObject DeviceObject = null ; JSONObject EventsObject = null ; JSONObject DeviceDetails = null ; private SharedPreferences settings = null ; Handler firstLoadHandler ; Handler eventsHandler ; ProgressDialog dialog ; Thread dataPreload ; Thread eventsLoad ; List < ZenossEvent > listOfZenossEvents = new ArrayList < ZenossEvent > ( ) ; ListView list ; ZenossEventsAdaptor adapter ; JSONArray Events = null ; private int EventCount = 0 ; @ Override public void onAttachedToWindow ( ) { } @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; settings = getSharedPreferences ( "rhybudd" , 0 ) ; setContentView ( view_zenoss_device ) ; list = ( ( ListView ) ( findViewById ( ZenossEventsList ) ) ) ; eventsHandler = new Handler ( ) { public void handleMessage ( Message msg ) { ( ( android . widget . ProgressBar ) ( findViewById ( R . id . eventsProgressBar ) ) ) . setVisibility ( 4 ) ; if ( ( ( EventCount ) > 0 ) && ( ( msg . what ) == 1 ) ) { adapter = new ZenossEventsAdaptor ( ViewZenossDevice . this , listOfZenossEvents , false ) ; list . setAdapter ( adapter ) ; } else { list = null ; } } } ; firstLoadHandler = new Handler ( ) { public void handleMessage ( Message msg ) { dialog . dismiss ( ) ; try { <START_BUG> if ( ( DeviceObject . getJSONObject ( "result" ) . getBoolean ( "success" ) ) == true ) { <END_BUG> DeviceDetails = DeviceObject . getJSONObject ( "result" ) . getJSONObject ( "data" ) ; try { ( ( TextView ) ( findViewById ( Title ) ) ) . setText ( DeviceDetails . getString ( "snmpSysName" ) . toUpperCase ( ) ) ; } catch ( Exception e ) { ( ( TextView ) ( findViewById ( Title ) ) ) . setText ( "No<seq2seq4repair_space>Name<seq2seq4repair_space>-<seq2seq4repair_space>Details" ) ; } try { ( ( TextView ) ( findViewById ( lastCollected ) ) ) . setText ( DeviceDetails . getString ( "lastCollected" ) ) ; } catch ( Exception e ) { ( ( TextView ) ( findViewById ( lastCollected ) ) ) . setText ( "-----" ) ; } try { ( ( TextView ) ( findViewById ( osModel ) ) ) . setText ( DeviceDetails . getJSONObject ( "osModel" ) . getString ( "name" ) ) ; } catch ( Exception e ) { ( ( TextView ) ( findViewById ( osModel ) ) ) . setText ( "Unknown<seq2seq4repair_space>OS" ) ; } try { ( ( TextView ) ( findViewById ( uptime ) ) ) . setText ( DeviceDetails . getString ( "uptime" ) ) ; } catch ( Exception e ) { } try { ( ( TextView ) ( findViewById ( productionState ) ) ) . setText ( DeviceDetails . getString ( "productionState" ) ) ; } catch ( Exception e ) { } String Groups = "" ; try { for ( int i = 0 ; i < ( DeviceDetails . getJSONArray ( "groups" ) . length ( ) ) ; i ++ ) { if ( i > 0 ) Groups += ",<seq2seq4repair_space>" ; try { Groups += DeviceDetails . getJSONArray ( "groups" ) . getJSONObject ( i ) . getString ( "name" ) ; } catch ( Exception e ) { } } ( ( TextView ) ( findViewById ( R . id . groups ) ) ) . setText ( Groups ) ; } catch ( Exception e ) { } String Systems = "" ; try { for ( int i = 0 ; i < ( DeviceDetails . getJSONArray ( "systems" ) . length ( ) ) ; i ++ ) { if ( i > 0 ) Systems += ",<seq2seq4repair_space>" ; Systems += DeviceDetails . getJSONArray ( "systems" ) . getJSONObject ( i ) . getString ( "name" ) ; } ( ( TextView ) ( findViewById ( R . id . systems ) ) ) . setText ( Systems ) ; } catch ( Exception e ) { BugSenseHandler . log ( "ViewZenossDevice" , e ) ; } } else { Toast . makeText ( ViewZenossDevice . this , "There<seq2seq4repair_space>was<seq2seq4repair_space>an<seq2seq4repair_space>error<seq2seq4repair_space>loading<seq2seq4repair_space>the<seq2seq4repair_space>Device<seq2seq4repair_space>details" , LENGTH_LONG ) . show ( ) ; finish ( ) ; } } catch ( Exception e ) { Toast . makeText ( ViewZenossDevice . this , "An<seq2seq4repair_space>error<seq2seq4repair_space>was<seq2seq4repair_space>encountered<seq2seq4repair_space>parsing<seq2seq4repair_space>the<seq2seq4repair_space>JSON." , LENGTH_LONG ) . show ( ) ; BugSenseHandler . log ( "ViewZenossDevice" , e ) ; } } } ; dialog = new ProgressDialog ( this ) ; dialog . setTitle ( "Contacting<seq2seq4repair_space>Zenoss" ) ; dialog . setMessage ( "Please<seq2seq4repair_space>wait:\nLoading<seq2seq4repair_space>Device<seq2seq4repair_space>details...." ) ; dialog . show ( ) ; dataPreload = new Thread ( ) { public void run ( ) { try { if ( ( API ) == null ) { API = new ZenossAPIv2 ( settings . getString ( "userName" , "" ) , settings . getString ( "passWord" , "" ) , settings . getString ( "URL" , "" ) ) ; } DeviceObject = API . GetDevice ( getIntent ( ) . getStringExtra ( "UID" ) ) ; } catch ( Exception e ) { firstLoadHandler . sendEmptyMessage ( 0 ) ; } firstLoadHandler . sendEmptyMessage ( 1 ) ; } } ; dataPreload . start ( ) ; eventsLoad = new Thread ( ) { public void run ( ) { try { if ( ( API ) == null ) { API = new ZenossAPIv2 ( settings . getString ( "userName" , "" ) , settings . getString ( "passWord" , "" ) , settings . getString ( "URL" , "" ) ) ; } EventsObject = API . GetDeviceEvents ( getIntent ( ) . getStringExtra ( "UID" ) ) ; Events = EventsObject . getJSONObject ( "result" ) . getJSONArray ( "events" ) ;

Fix:
if ( ( ( ( DeviceObject ) != null ) && ( ( msg . what ) == 1 ) ) && ( ( DeviceObject . getJSONObject ( "result" ) . getBoolean ( "success" ) ) == true ) ) {