程序中运行的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();
}
}