wpadebug: Add exception handling for missing resources

These errors should not really happen, but apparently they can if the
build dependencies get messed up somehow.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-05-05 18:28:25 +03:00
parent 55a2df4389
commit d7232a8da6
2 changed files with 16 additions and 4 deletions

View File

@ -77,8 +77,14 @@ public class CommandListActivity extends ListActivity
Toast.LENGTH_SHORT).show();
}
InputStream inres = getResources().openRawResource(R.raw.shell_commands);
read_commands(list, new Scanner(inres));
InputStream inres;
try {
inres = getResources().openRawResource(R.raw.shell_commands);
read_commands(list, new Scanner(inres));
} catch (android.content.res.Resources.NotFoundException e) {
Toast.makeText(this, "Could not read internal resource",
Toast.LENGTH_SHORT).show();
}
ArrayAdapter<CmdList> listAdapter;
listAdapter = new ArrayAdapter<CmdList>(this, android.R.layout.simple_list_item_1, list);

View File

@ -59,8 +59,14 @@ public class WpaCommandListActivity extends ListActivity
Toast.LENGTH_SHORT).show();
}
InputStream inres = getResources().openRawResource(R.raw.wpa_commands);
read_commands(list, new Scanner(inres));
InputStream inres;
try {
inres = getResources().openRawResource(R.raw.wpa_commands);
read_commands(list, new Scanner(inres));
} catch (android.content.res.Resources.NotFoundException e) {
Toast.makeText(this, "Could not read internal resource",
Toast.LENGTH_SHORT).show();
}
ArrayAdapter<CmdList> listAdapter;
listAdapter = new ArrayAdapter<CmdList>(this, android.R.layout.simple_list_item_1, list);