我想捕获这个错误,以便我可以自己处理它而不向用户显示它。我该怎么做???
我正在使用适用于 Windows Azure 的 Android 官方 SDK。
此错误仅出现 2-3% 的时间。所有其他时间它连接良好。
此外,如果我尝试联系 azure 的活动不再存在,则上下文不再存在,它会尝试在不存在的上下文中显示消息,这将使应用程序崩溃。
此代码基本上直接来自 windows azure 的 todolist 示例。
谢谢,
安东尼·G。
try {
// Create the Mobile Service Client instance, using the provided
// Mobile Service URL and key
mClient = new MobileServiceClient(
"XXXXXXX",
"YYYYYYYYY", this)
.withFilter(new ProgressFilter());
createTable();
} catch (MalformedURLException e) {
createAndShowDialog(
new Exception(
"There was an error creating the Mobile Service. Verify the URL"),
"Error");
} catch (Exception e) {
Log.d(TAG, "Exepction caught" + e.toString());
}
这是表创建部分。
try {
Log.d(TAG, "Create table called and started. ");
// Get the Mobile Service Table instance to use
// Don't use the default, because the table on Azure has a different name than the class, instead use this call.
mToDoTable = mClient.getTable("MY_TABLE",
MY_TABLE_SPECIAL_CLASS.class);
// Create an adapter to bind the items with the view
mAdapter = new DownloadedMapsListAdapter(this, R.layout.row_list_show_maps_to_download);
ListView listViewToDo = (ListView) findViewById(R.id.listview_data_fromAzure);
//listViewToDo.setOnItemClickListener(mMessageClickedHandler);
listViewToDo.setAdapter(mAdapter);
// Load the items from the Mobile Service
refreshItemsFromTable();
} catch (Exception e) {
Log.d(TAG, "Exepction caught" + e.toString());
}