cheli_71 于 2013.09.28 14:43 提问
- 如果互联网或信号下降如何捕获一个异常?
-
程序中运行的mediaplayer 和 streaming audio ,我想知道如果互联网或信号下降使用什么样的方法能在捕捉异常?
private class taskDoSomething extends AsyncTask<Void, Void, List<Employee>> { @Override protected List<Employee> doInBackground(Void... params) { String url = "http://ofertaweb.ro/android/sleepandlovemusic/list_files.php"; try { Get_Webpage obj = new Get_Webpage(url); directory_listings = obj.get_webpage_source(); } catch (Exception e) { Toast.makeText(this, "You have to be connected to the internet for this application to work", Toast.LENGTH_LONG).show(); finish(); } }
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!