ECn Categories > Blocked Aplication (BA) > Partially Blocked (PB)
It covers the cases in which the app does not respond to commands given by the user, but just for a short period of time. After waiting, the app just keeps working normally and sometimes displays a message indicating that there was an issue.
Amount of Issues | App List |
---|---|
1 | (A6) Pressurenet |
Examples
PressureNet
The following code snippets show the classes and files that are involved in the generation of the previuos issue.
In order to see how this error is generated, we need to review all the flow event. First, we have the “onCreate” for the class that respond to the user when the app is open. In this method at line 374 the “setUpUIListeners” method is called.
src/ca/cumulonimbus/barometernetwork/BarometerNetworkActivity.java
358. public void onCreate(Bundle savedInstanceState) {
...
374. setUpUIListeners();
This method is in charge of attaching the listeners to GUI elements. In this specific case we care about 2, the first one is the “editLocation” that represent the editText element in the layout. The second one is “buttonGoLocation”, this object represents the button used to trigger the search process.
src/ca/cumulonimbus/barometernetwork/BarometerNetworkActivity.java
private void setUpUIListeners() {
Context context = getApplicationContext();
mInflater = LayoutInflater.from(context);
progressAPI = (ProgressBar) findViewById(R.id.progressBarAPICalls);
buttonGoLocation = (ImageButton) findViewById(R.id.buttonGoLocation);
editLocation = (EditText) findViewById(R.id.editGoLocation);
So, when the button is clicked the process defined from line 2050 on is executed. It worth noting, at line 2064 that an instance of a “Geocoder” is created. This class is part of the Android SDK, so based in the official documentation the method “getFromLocationName” used at line 2066, blocks while the query is done causing the temporal block of the app. Also, as is shown in the documentation the method throws an IOException when there is no connection stablished.
src/ca/cumulonimbus/barometernetwork/BarometerNetworkActivity.java
2050. buttonGoLocation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String location = editLocation.getText().toString().trim();
if (location.equals("")) {
displayMapToast(getString(R.string.locationPrompt));
focusSearch();
return;
}
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editLocation.getWindowToken(), 0);
editLocation.setCursorVisible(false);
2064. Geocoder geocode = new Geocoder(getApplicationContext());
try {
2066. List<Address> addr = geocode.getFromLocationName(location,
2067. 2);
Therefore, due to the connectionless state of the scenario the previous method throws an IOException and at line 2106 the catch clause handles it and trigger the process to display a Toast with the error message.
src/ca/cumulonimbus/barometernetwork/BarometerNetworkActivity.java
} catch (IOException ioe) {
2106. displayMapToast(ioe.getMessage());
ioe.printStackTrace();